Boost logo

Boost :

From: Valentin Bonnard (Bonnard.V_at_[hidden])
Date: 2000-07-29 19:01:26

David Abrahams wrote:

> Unfortunately, the solution proposed below is unacceptable, because it would
> allow construction of shared_ptr<X> from shared_ptr<Y> even where X and Y
> are unrelated types.

I don't see how this would be possible with the proposed code.

The reinterpre_cast is ugly and causes undefined behaviour since
isn't a POD, but I'd bet it will work in practice.

What is proposed is bugware (ie, having the wrong behaviour (invoking
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
make everything public.

If some idiot tries to access undocumented members that are public by
accident it's only his problem, let's not loose time on this.

Proposed code was:

> > template<typename Y>
> > shared_ptr(const shared_ptr<Y>& r) throw() : px(r.get()) {
> > ++*(pn = reinterpret_cast<const shared_ptr<T>&>( r ).pn);
> > }
> > #else // original version

Valentin Bonnard

Boost list run by bdawes at, gregod at, cpdaniel at, john at