
For performance reasons I would like to see something like the following conversion operators in shared_ptr<T>: template<class T> class shared_ptr { public: ... template<class S> operator shared_ptr<S>&() throw() { BOOST_STATIC_ASSERT(T* is convertible to S*); return reinterpret_cast<shared_ptr<S>&>(*this); } template<class S> operator const shared_ptr<S>&() throw() const { BOOST_STATIC_ASSERT(T* is convertible to S*); return reinterpret_cast<const shared_ptr<S>&>(*this); } }; // class shared_ptr<T> This would mimic the standard conversion from T* to S* without any performance penalty for shared_ptr<T>. Konstantin "Michele Galante" <m.galante@centrosistemi.it> schrieb im Newsbeitrag news:4020B616.7040900@centrosistemi.it...
So I have something like this:
std::vector<boost::shared_ptr<Base> > BaseVector;
void add(boost::shared_ptr<Base>& newOne) { BaseVector.push_back(newOne); }
and I call it like this usually : boost::shared_ptr<Derived> p(new Derived); add(p);
I think the problem is you take a reference to the shared_ptr. Try this way:
void add(boost::shared_ptr<Base> newOne) { BaseVector.push_back(newOne); }
-- Michele Galante Zucchetti Centro Sistemi SPA m.galante@centrosistemi.it