Because SWIG does not understand boost types, type characters must be written. Here are a couple of typemaps for boost::optional<int>.
From Python, Noneor an integer can be passed to a function:
%typemap(in) boost::optional<int> %{
if($input == Py_None)
$1 = boost::optional<int>();
else
$1 = boost::optional<int>(PyLong_AsLong($input));
%}
boost::optional<int> None Python:
%typemap(out) boost::optional<int> %{
if($1)
$result = PyLong_FromLong(*$1);
else
{
$result = Py_None;
Py_INCREF(Py_None);
}
%}