Boost logo

Boost Users :

Subject: Re: [Boost-users] shared_ptr downcast
From: Igor R (boost.lists_at_[hidden])
Date: 2008-12-23 05:39:15


2008/12/23 Jason Cipriani <jason.cipriani_at_[hidden]>:
> If I have:
>
> class Base { };
> class Derived : public Base { };
>
> And a container, e.g.:
>
> std::vector<boost::shared_ptr<Base> > objs;
>
> How do I downcast to a shared_ptr<Derived>? E.g.:
>
> boost::shared_ptr<Derived> d = (boost::shared_ptr<Derived>)objs[0];
>

Look at boost::static_pointer_cast


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net