Boost logo

Boost :

From: gn_at_[hidden]
Date: 2000-08-01 04:59:07


>
> The reinterpre_cast is ugly and causes undefined behaviour since
> shared_ptr
> isn't a POD, but I'd bet it will work in practice.
>
> What is proposed is bugware (ie, having the wrong behaviour
(invoking
> undefined
> behaviour) because someone else had the wrong behaviour (not
handling
> standard C++)). Bugware is generaly bad; here I think it is the
wrong
> solution because another simplier and working solution is already in
> use:
> make everything public.
>

Gee, what a lively discussion - I hadn't expected that :-)

I'm fully aware that my proposal is ugly, but the code would be
encapsulated by a macro that effectivly stated that this code would
only be compiled when using a non-conforming (and therefore already
buggy) compiler. Plus, the external interface of the class would be
the one we originally designed, without having to sacrifice
encapsulation.

#ifdef _MSC_VER

:-) Now we already know which compiler we're targeting, so we can as
well prove that the "undefined behaviour code" does produce
predictable results with that one compiler. In my case, the
reinterpret_cast could only fail if the compiler created different
class layouts for different instantiations of "shared_ptr", which it
doesn't do because the rest of the code alreaday guarantees
compatibility between the pointer types.

#endif

Cheerio, Gernot


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk