[C++-sig] shared_ptr converters
David Abrahams
dave at boost-consulting.com
Tue Apr 15 19:07:14 CEST 2003
Nicodemus <nicodemus at globalite.com.br> writes:
> BOOST_PYTHON_MODULE(test)
> {
> class_<A, A_Wrapper, boost::noncopyable, boost::shared_ptr<A> >("A")
> ;
>
> def("New", &New);
> } The code compiles fine, without any errors or warnings. Now,
> inside Python:
>
> ActivePython 2.2.2 Build 224 (ActiveState Corp.) based on
> Python 2.2.2 (#37, Nov 26 2002, 10:24:37) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>>
> >>> from test import *
> >>> New()
> Traceback (most recent call last):
> File "<stdin>", line 1, in ?
> TypeError: No to_python (by-value) converter found for C++ type: class
> boost::shared_ptr<struct A>
> >>>
>
> Is this a bug, or am I missing something? I tried changing the order
> of the template parameters of class_, but then the code either doesn't
> compile, or compiles but gives the same results (I don't think the
> error messages from the compiler are revelant in this case, but I will
> post if there's need).
What happens if you get rid of boost::noncopyable and give f a default
implementation (but use the same wrapping code otherwise)? If
everything works, it is a bug wherein noncopyable prevents
registration of the converter for the holding smart pointer.
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list