[C++-sig] Re: creating an instance of a class_<> object in c+ + an d exporting it to python

Max Khesin MKhesin at liquidnet.com
Fri Aug 13 22:03:33 CEST 2004


> Max Khesin <MKhesin at liquidnet.com> writes:
> 
> > Maybe I missed something, but I think this should work for you:
> >
> > class_<A, A*, boost::noncopyable> classA("A", noinit);// 
> this is the class
> > object - only one registration!
> > classA.def("f1", &A::f1)
> >   ....
> >   ;
> > CPPObj cppObj;
> > object instanceOfA1 = classA(&cppObj);// multiple instances
> > object instanceOfA2 = classA(&cppObj);
> 
> 
> Or:
> 
>    object classA 
>      = class<A, A*, boost::noncopyable>("A", noinit)
>           .def("f1", &A::f1)
>           ...
>           ;

In style! Nice. Also the OP wants to 
"create an instance of a wrapped object "A", initializing it using
    a  pointer to an existing instance of a C++ A object." so I assume
something like this is needed:

    object classA 
      = class<A, A*, boost::noncopyable>("A", CPPObj*)
           .def("f1", &A::f1)
           ...
           ;



> Dave Abrahams
> Boost Consulting
> http://www.boost-consulting.com
> 
> _______________________________________________
> C++-sig mailing list
> C++-sig at python.org
> http://mail.python.org/mailman/listinfo/c++-sig
> 
This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the system manager. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20040813/768d83d0/attachment.htm>


More information about the Cplusplus-sig mailing list