[C++-sig] Re: implicitly_convertible<> & auto_ptr

David Abrahams dave at boost-consulting.com
Wed Feb 19 18:15:27 CET 2003


"Nicolas Lelong" <nico_ml at mgdesign.org> writes:

>> Can't you do it with a wrapper?
>> addBigDataDerived(BigDataStore &store, char const* name,
> std::auto_ptr<BigDataDerived> data){store.addBigData(name,data);}
>>   python::class_<BigDataStore, boost::noncopyable>("BigDataStore")
>>     .def("addBigData", &BigDataStore::addBigData,
> python::with_custodian_and_ward<1,2>() )
>>     .def("addBigData", &addBigDataDerived,
> python::with_custodian_and_ward<1,2>() );
>
> Ooops, by the way, it should be "python::with_custodian_and_ward<1,3>()" but
> I do wonder if it's really useful because of the auto_ptr stuff already
> stating a transfer of ownership.

Not only un-useful, but mistaken.  with_custodian_and_ward<> manages
ownership of Python objects so that it matches non-owning reference
acquisition on the C++ side.  Perhaps it should be called
"acquires_internal_reference" instead.

-- 
Dave Abrahams
Boost Consulting
www.boost-consulting.com





More information about the Cplusplus-sig mailing list