[C++-sig] problem with constructor/implicitly_convertible

Ralf W. Grosse-Kunstleve rwgk at yahoo.com
Fri Feb 4 23:52:32 CET 2005


--- Jonathan Brandmeyer <jbrandmeyer at earthlink.net> wrote:

> I'm concerned that storage.bytes is only guaranteed to have enough room
> for one Base object, and that the placement new operation may be placing
> a new object of Derived into an inadequate chunk of storage.  This
> example doesn't crash, and Valgrind doesn't report any errors, but I
> just don't see how a converter registered for Base can possibly know how
> much storage to allocate for Derived.

I guess as long as XXXXXX

        (boost::python::converter::rvalue_from_python_storage<XXXXXX>*)
          	data)->storage.bytes;
      	new (storage) XXXXXX(...);
	data->convertible = storage;

matches the memory handling should be fine.

In your example you don't use inheritance even though that seems to be your
original question. Did you think about making the example more like what you
want in the end? I think you should be able to do what you want, but I don't
know if you need to register one or two converters. To get the answer I'd
simply try it out.

Ralf

P.S.: Every time I cook up a new converter I run it through valgrind (since is
is one of the few places where Boost.Python doesn't give you any protection).



		
__________________________________ 
Do you Yahoo!? 
Yahoo! Mail - 250MB free storage. Do more. Manage less. 
http://info.mail.yahoo.com/mail_250



More information about the Cplusplus-sig mailing list