Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2001-07-24 10:34:19


From: Peter Dimov <pdimov_at_[hidden]>
> From: <greg_at_[hidden]>
> > This looks like a good start, thanks. I think do_dynamic_cast is the
> > name we previously agreed on for your shared_dynamic_cast, and that
> > we wanted a version that worked for raw pointers as well.
>
> If do_dynamic_cast is supposed to be a generalization of dynamic_cast:
>
> template<class R, class T> R do_dynamic_cast(T /* const */ &);
>
> (dynamic_cast<U*> returns U*, dynamic_cast<U&> returns U&)
>
> then dynamic-casting a shared_ptr would look like
>
> do_dynamic_cast<shared_ptr<X> >(y); // 1
>
> whereas with a shared_ptr-specific cast the syntax would be
>
> shared_dynamic_cast<X>(y); // 2
>
> I prefer (2). (1) is more generic but I can't see how the genericity would
> be exploited.

It could be exploited in generic code that didn't care whether
it was operating on raw pointers or smart pointers?


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