【发布时间】:2010-06-10 01:07:18
【问题描述】:
我想将 const-ness 从 boost::shared_ptr 中剔除,但我 boost::const_pointer_cast 不是答案。 boost::const_pointer_cast 想要 const boost::shared_ptr<T>,而不是 boost::shared_ptr<const T>。让我们放弃强制性的“你不应该那样做”。我知道...但我需要这样做...那么最好/最简单的方法是什么?
为了清楚起见:
boost::shared_ptr<const T> orig_ptr( new T() );
boost::shared_ptr<T> new_ptr = magic_incantation(orig_ptr);
我需要知道魔法咒语()
【问题讨论】:
标签: c++ boost casting constants shared-ptr