|
Boost : |
From: Eric Ford (eford_at_[hidden])
Date: 2001-05-19 11:51:44
--- In boost_at_y..., "Rainer Deyke" <root_at_r...> wrote:
> The correct value if 'bp' at this point is '0'. Your function does
not
> mirror this behavior. The following fixes that problem:
>
> template<typename T, typename U>
> inline shared_ptr<T>& sp_dynamic_cast(const shared_ptr<U>& a)
> {
> if (dynamic_cast<T *>(a.get()) {
> return *(shared_ptr<T>*)&a;
> }
> return shared_ptr<T>(0);
> }
Agreed about the returning 0. But isn't there a problem here with
returning a temporary? I changed ito to inline shared_ptr<T>&
sp_dynamic_cast(const shared_ptr<U>& a)
E
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk