[C++-sig] preventing a copy of the vector when using the vector_indexing_suite

Scott McKay skottmckay at gmail.com
Fri Sep 23 01:52:52 CEST 2005


FWIW Finally had a chance to get back to this and found a way to make it
work.

If I remove the implicit conversion from smart_ptr<Factory> to
smart_ptr<Factory_wrapper> in the base class export all is good.

Not sure why that leads to the loop and seg fault if you derive from
BasicFactory in python though.


On 8/19/05, Scott McKay <skottmckay at gmail.com> wrote:
>
>
> That has led me to a question on what is required in terms of implicit
> conversion calls to handle classes in the same hierarchy that are
> wrapped with wrapper<> and held by smart pointers. I can't seem to
> find a combination to allow derivation from both Factory and
> BasicFactory.
>
> void Export_Factory()
> {
> class_< Factory_Wrapper, smart_ptr< Factory_Wrapper > >("Factory",
> init< >())
> .def("generate", &Factory::generate,
> &Factory_Wrapper::default_generate, return_self<>())
> .def(init< const Factory& >())
> ;
>
> implicitly_convertible< smart_ptr< Factory_Wrapper >, smart_ptr<
> Factory > >();
> implicitly_convertible< smart_ptr< Factory >, smart_ptr<
> Factory_Wrapper > >();
> }
>
>
>
> void Export_BasicFactory()
> {
> class_< BasicFactory_Wrapper, bases< Factory > , smart_ptr<
> BasicFactory_Wrapper > >("BasicFactory", init< >())
> .def("generate", (Factory& (BasicFactory::*)(SourceGroup&)
> )&BasicFactory::generate, (Factory&
>
> (BasicFactory_Wrapper::*)(SourceGroup&))&BasicFactory_Wrapper::default_generate,
> return_self<>())
> .def(init< const BasicFactory& >())
> ;
>
> implicitly_convertible< smart_ptr< BasicFactory_Wrapper >,
> smart_ptr< Factory > >();
> implicitly_convertible< smart_ptr< Factory >, smart_ptr<
> BasicFactory_Wrapper > >();
> }
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/cplusplus-sig/attachments/20050922/7259874b/attachment.htm>


More information about the Cplusplus-sig mailing list