|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-07-24 16:07:46
From: "Greg Colvin" <gcolvin_at_[hidden]>
[...]
> > Still, I prefer that shared_dynamic_cast<> be left as an option. More
> > focused (less generic) interfaces are less error prone, when genericity
is
> > not required.
>
> Yes, although I think a shared_ptr member function is the right
> way to go for that purpose.
A member function has that awkward (when it even works)
p.template cast<X>()
syntax. :-)
I'd provide a constructor
template<class U> shared_ptr<T>::shared_ptr(shared_ptr<U> const &,
dynamic_cast_tag);
as a helper (to avoid the troublesome friend declarations) and a free
function
template<class U, class T> shared_ptr<U> shared_dynamic_cast(shared_ptr<T>
const & p)
{
return shared_ptr<U>(p, dynamic_cast_tag);
}
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk