Hi,
In my new company we are using Boost.Python. Boost version is 1.33.1.
It's my first steps with the library, so please bare with me if this is
something trivial.
I've got this noncopyable class Foo
class Foo : boost::noncopyable { /*...*/ };
and shift operator defined:
Foo&
operator<<( Foo& foo, int )
{
...
return foo;
}
Here is my export statement (FooSP is smart pointer on Foo
using namespace boost::python;
class_( "Foo", no_init )
.def( self << int() )
;
Here is my Python script extract that is being executed from C++
"foo << 2 << 4"
I never got to the second shift call. Instead I an getting exception from
Boost.Python:
TypeError: No to_python (by-value) converter found for C++ type: class A
I kinda found couple ways to deal with it:
1. define operator<< to return FooSP, which I do not like for assymetry and
other reasons
2. avoid using self << int() and define explicit function:
Foo&
shift_op( Foo& foo, int )
{
...
return foo;
}
...
.def( "__lshift__", &shift_op, return_internal_reference<1>() )
What is the proper way to deal with it? And why original error is reported?
Gennadiy