|
Boost Users : |
Subject: [Boost-users] shared_ptr downcast
From: Jason Cipriani (jason.cipriani_at_[hidden])
Date: 2008-12-23 04:36:41
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];
I have a function that takes a shared_ptr<Derived> and all I have is a
shared_ptr<Base>. I don't mind static_cast behavior, although
dynamic_cast behavior would be ideal.
Thanks,
Jason
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