Boost C++ Libraries: Ticket #11259: boost::movelib::unique_ptr is not convertible to boost::shared_ptr https://svn.boost.org/trac10/ticket/11259 <p> I'm working on porting some code to a platform without a C++11 standard library, and wanted to use the Boost versions of shared_ptr and unique_ptr. Unfortunately code like this doesn't work: </p> <pre class="wiki">namespace mystd { using boost::shared_ptr; using boost::make_shared; using boost::movelib::unique_ptr; using boost::movelib::make_unique; } mystd::unique_ptr&lt;int&gt; load_thing() { return mystd::make_unique&lt;int&gt;(1); } mystd::shared_ptr&lt;int&gt; get_thing() { return load_thing(); } </pre><p> because there is no conversion from movelib::unique_ptr to shared_ptr. </p> <p> I'm happy to submit a patch that adds it but I'm not sure whether it's okay to add a Boost.Move dependency to Boost.<a class="missing wiki">SmartPtr</a>. And if I do that, should I also add move emulation to boost::shared_ptr? C++03 users might like the performance benefit of moving them instead of copying them. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/11259 Trac 1.4.3 Peter Dimov Sun, 03 May 2015 22:15:08 GMT <link>https://svn.boost.org/trac10/ticket/11259#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11259#comment:1</guid> <description> <p> Should be fixed in <a class="ext-link" href="https://github.com/boostorg/smart_ptr/commit/d875a68ceb10081e30529e65ddef47297844e9f8"><span class="icon">​</span>https://github.com/boostorg/smart_ptr/commit/d875a68ceb10081e30529e65ddef47297844e9f8</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Peter Dimov</dc:creator> <pubDate>Sun, 03 May 2015 22:24:17 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/11259#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/11259#comment:2</guid> <description> <p> Well, not exactly fixed. Under g++ (in C++03 mode) at least, your code still doesn't work. You need to do </p> <pre class="wiki">mystd::shared_ptr&lt;int&gt; get_thing() { mystd::shared_ptr&lt;int&gt; r( load_thing() ); return r; } </pre><p> This: </p> <pre class="wiki"> mystd::shared_ptr&lt;int&gt; r = load_thing(); </pre><p> doesn't work either. </p> <p> VC++ doesn't mind. </p> </description> <category>Ticket</category> </item> </channel> </rss>