[C++-sig] shared_ptr converters

Nicodemus nicodemus at globalite.com.br
Tue Apr 15 22:48:15 CEST 2003


David Abrahams wrote:

>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.
>

Removing boost::noncopyable didn't help, it compiles fine (I just had to 
add a copy constructor to the wrapper class, which was expected), but 
calling New() raises the same exception. Now, removing the wrapper class 
and putting back boost::noncopyable worked fine. For clarification:

   BOOST_PYTHON_MODULE(test)
   {
       class_<A, boost::noncopyable, boost::shared_ptr<A> >("A")
       ;

       def("New", &New);
   } 

So, it is related to the wrapper class. Here it is again:

   struct A_Wrapper: A
   {
       A_Wrapper(PyObject* self_):
           A(), self(self_) {}
      
       A_Wrapper(PyObject* self_, const A& a):
           A(a), self(self_) {}

       int f() {
           return call_method< int >(self, "f");
       }

       PyObject* self;
   };

Any ideas?

Regards,
Nicodemus.






More information about the Cplusplus-sig mailing list