[C++-sig] Re: discard reference
David Abrahams
dave at boost-consulting.com
Tue Sep 16 16:46:41 CEST 2003
"Mike Rovner" <mike at nospam.com> writes:
> David Abrahams wrote:
>> "Mike Rovner" <mike at nospam.com> writes:
>>> Wrapper signature is (_1, ap<A*>)
>>> and I'm calling with AA* (or ap<AA> - doesn't work either).
>>>
>>> And if I set wrapper as (_1, ap<AA*>) I'll loose ability to polimorf
>>> derived classes
>>> and will have to write wrappers for each derived class individually
>>> which is inelegant.
>>
>> Oh, I completely overlooked that. Do you really intend to use
>> auto_ptr<A*>? Those point at A* objects, not at A objects.
>
> Oh, sorry. It's just mistyping of auto_ptr<A>. (I'm not used to auto_ptr
> yet.)
> Everywhere in the code there are auto_ptr<A>.
>
> So I'm trying to invent some kind of automatic auto_ptr argument processing
> policy: release_auto_ptr_policy
> .def("X", (void)(*X)(auto_ptr(A))&X, release_auto_ptr_policy)
> which will call X with released A*, e.g.
> Auto_X_wrapper(auto_ptr<A> ap) { X(ap.get()); ap.release(); }
>
> What do you think? I even tryed to look into implementation, but get lost.
> :(
I think we'll want something like this eventually, anyway. Luabind
can do that and the langbinding integration will produce the result
you want.
I'm not really sure what you mean by "_1" above, but I think you can
get the polymorphism you want (laboriously) by using
implicitly_convertible<std::auto_ptr<Derived>,std::auto_ptr<Base> >();
for all the appropriate Derived classes.
HTH,
--
Dave Abrahams
Boost Consulting
www.boost-consulting.com
More information about the Cplusplus-sig
mailing list