boost::shared_ptr<const T> to boost::shared_ptr<T>
Posted
by Flevine
on Stack Overflow
See other posts from Stack Overflow
or by Flevine
Published on 2010-06-10T01:07:18Z
Indexed on
2010/06/10
1:12 UTC
Read the original article
Hit count: 257
I want to cast the const-ness out of a boost::shared_ptr, but I boost::const_pointer_cast is not the answer. boost::const_pointer_cast wants a const boost::shared_ptr, not a boost::shared_ptr. Let's forego the obligitory 'you shouldn't be doing that'. I know... but I need to do it... so what's the best/easiest way to do it?
For clarity sake:
boost::shared_ptr<const T> orig_ptr( new T() );
boost::shared_ptr<T> new_ptr = magic_incantation(orig_ptr);
I need to know the magic_incantation()
Thanks!
© Stack Overflow or respective owner