[C++-sig] Re: Possible bug with HeldType?

David Abrahams dave at boost-consulting.com
Fri Aug 8 23:23:46 CEST 2003


Prabhu Ramachandran <prabhu at aero.iitm.ernet.in> writes:

> Hi,
>
>>>>>> "DA" == David Abrahams <dave at boost-consulting.com> writes:
>
>     >> I could swear that this code used to work fine a month back.
>     >> BTW, the new traceback is a nice change from the original
>     >> unhelpful RuntimeError, thanks!
>
>     DA> Use a more-modern GCC and you'll get real type names in there
>     DA> as well.
>
> Thats nice!
>
>     >> Anyway, I changed:
>     >>   void add_wrapper(Holder* c, std::auto_ptr< A > o)
>     >> to read like so:
>     >>   void add_wrapper(Holder* c, std::auto_ptr< A_Wrapper > o)
>     >> So is this a bug or am I or Pyste doing something wrong?
>
>     DA> It surprises me that you're saying the same C++ code worked a
>     DA> month ago.  I don't see how that's possible.
>
> It has been about a month since I touched this code and back then,
> IIRC, it was working fine.  I had a small example that I was using to
> experiment with std::auto_ptr.  From what I can remember it worked
> then.  That was a while back and I might have made some kind of
> mistake or perhaps not tested it carefully enough.  One possibility is
> that I tested it with a class that had no virtual functions and
> therefore no wrapper class.  

Sounds likely.

> Unfortunately, I'm unable to find any hard evidence.  Its most
> likely that I didn't test carefully enough.
>
> Anyway, from your response I understand that for classes with
> virtual functions I need the add_wrapper function to use
> std::auto_ptr<A_Wrapper> and not std::auto_ptr<A>.  

No, you can write 

    implicitly_convertible<
        std::auto_ptr<A_Wrapper>, std::auto_ptr<A>
    >();

> This is a bit of a pain with Pyste since if Nicodemus changes the
> name of the wrapper class I'd have to change the pyste files.  Its
> easy to get things working now since I know how the wrapper classes
> are named.  Is there an alternative way to do this that insulates
> the user from future changes to the wrapper name?

Not that I know of; I guess Nicodemus ought to do this
implicitly_convertible trick himself.

Hmm, Boost.Python could detect that case and do it for you.

> Thanks and sorry for the false alarm.

Sure thing.

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





More information about the Cplusplus-sig mailing list