[C++-sig] newbie questions

David Abrahams dave at boost-consulting.com
Mon Oct 7 20:49:14 CEST 2002


Stefan Seefeld <seefeld at sympatico.ca> writes:

> David Abrahams wrote:
> 
> > How about using boost::shared_ptr<Foo> as your HeldType and returning
> > boost::shared_ptr<Foo> from your factory function?
> 
> ok. Now I have
> 
>     python::class_<Foo,
>                    boost::shared_ptr<Foo>,
>                    boost::noncopyable> hello("Foo");
> 
> but the compiler complains. You use a 'assert_default_constructible'
> class to make sure 'Foo' can be default-constructed, though obviously
> in my case it shouldn't (only the factory should construct 'Foo's).
> What am I missing ?

     python::class_<Foo,
                    boost::shared_ptr<Foo>,
                    boost::noncopyable> hello("Foo", no_init);
                                                     ^^^^^^^
-or-

     python::class_<Foo,
                    boost::shared_ptr<Foo>,
                    boost::noncopyable> hello("Foo", init<Arg1, Arg2>());

etc...

-- 
           David Abrahams * Boost Consulting
dave at boost-consulting.com * http://www.boost-consulting.com





More information about the Cplusplus-sig mailing list