[C++-sig] Re: discard reference

Mike Rovner mike at nospam.com
Tue Sep 16 00:40:10 CEST 2003


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.
:(

Mike







More information about the Cplusplus-sig mailing list