[C++-sig] Re: operator ->, cast operator

David Abrahams dave at boost-consulting.com
Sun Mar 13 01:17:25 CET 2005


"Leonard \"paniq\" Ritter" <paniq at paniq.org> writes:

> appending i should say that the code compiled, but i still had no access 
> on View's methods. i modified the code so that the export of Ptr<> was 
> removed (i assume it was not needed anymore), and so i'm left with an 
> abstract class export with a custom smart pointer that doesnt give me 
> any benefit because i dont have access to the smart pointers
> constructor 

Use make_constructor to register the constructor for the smart pointer
in the View export.

> (which a shortcut to looking up the library from the class id, loading 
> it, resolving the factory function and obtaining a new object) - that 
> means using Ptr<> as HeldType does not seem to let me use the interface 
> instantiations in the fashion i wanted to from python.
>
> given that Ptr<> itself exports a few nice methods i want to use from 
> python (such as factory constructors and interface querying methods), is 
> there any chance of exposing these?

Sure; just make thin wrapper functions that take a Ptr<View>& as the
first argument and then def them.  In fact, I don't think you need the
thin wrappers and you can just 

  .def("foo", &Ptr<View>::foo)

in your class_<View,...> construct.
-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com




More information about the Cplusplus-sig mailing list