Boost C++ Libraries: Ticket #10488: Compilation of serializing shared_ptr<const Object> fails https://svn.boost.org/trac10/ticket/10488 <p> Compilation of code that includes serialization of shared_ptr&lt;const Object&gt; fails with Boost 1.56.0 with error: </p> <pre class="wiki">/usr/include/boost/smart_ptr/shared_ptr.hpp:323:25: note: no known conversion for argument 1 from ‘const boost::shared_ptr&lt;const TestClass&gt;’ to ‘const boost::shared_ptr&lt;void&gt;&amp;’ </pre><p> This works with Boost 1.55.0 and earlier versions. Tested on Arch Linux with clang 3.4.2 and g++ 4.9.1. </p> <p> Here's a little test to replicate the problem: </p> <pre class="wiki">#include &lt;fstream&gt; #include &lt;boost/archive/text_iarchive.hpp&gt; #include &lt;boost/serialization/shared_ptr.hpp&gt; #include &lt;boost/make_shared.hpp&gt; class TestClass { public: TestClass(int i) : _i(i) {} private: friend class boost::serialization::access; TestClass() {} template&lt;class Archive&gt; void serialize(Archive &amp; ar, const unsigned int version) { ar &amp; _i; } int _i; }; typedef boost::shared_ptr&lt;TestClass&gt; ClassPtr; typedef boost::shared_ptr&lt;const TestClass&gt; ConstClassPtr; int main(int argc, char* argv[]) { ClassPtr ptr = boost::make_shared&lt;TestClass&gt;(13); ConstClassPtr cPtr = boost::make_shared&lt;const TestClass&gt;(42); { std::ifstream ifs("test"); boost::archive::text_iarchive ia(ifs); ia &gt;&gt; ptr; // This works ia &gt;&gt; cPtr; // This doesn't } return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10488 Trac 1.4.3 visa.jokelainen@… Wed, 10 Sep 2014 12:56:00 GMT <link>https://svn.boost.org/trac10/ticket/10488#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:1</guid> <description> <p> The problem sounds a lot like regression of this previous ticket: <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/3123"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/3123</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Mon, 15 Sep 2014 15:08:46 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10488#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:2</guid> <description> <p> Actually this change looks like an improvement to me. </p> <p> a const <a class="missing wiki">TestClass</a> is something that shouldn't be modifiable </p> <p> ia &gt;&gt; cPtr would do just that. </p> <p> I don't remember any specific change which would affect this, but the current behavior seems to be the correct one to me. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Tue, 23 Sep 2014 20:17:27 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10488#comment:3 https://svn.boost.org/trac10/ticket/10488#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">duplicate</span> </li> </ul> <p> see <a class="ext-link" href="https://svn.boost.org/trac/boost/ticket/3123"><span class="icon">​</span>https://svn.boost.org/trac/boost/ticket/3123</a> </p> Ticket reder <rouge.richard@…> Wed, 29 Oct 2014 10:10:38 GMT <link>https://svn.boost.org/trac10/ticket/10488#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:4</guid> <description> <p> This is a regression. Not being able to serialize a shared_ptr&lt;const Object&gt; is indeed very painful. Ticket 3123 shows it is not absurd: imagine I have a </p> <p> <code> typedef map&lt;string,shared&lt;book&gt;&gt; library; </code> </p> <p> Since I do not want people to write on the books, I'd prefer a </p> <p> <code>typedef map&lt;string,shared&lt;const book&gt;&gt; library;</code> </p> <p> and be able to write/load the contents of my library. </p> <p> Anyhow, it seems to be just a matter of changing line 59 of serialization/shared_ptr_helper.cpp from </p> <pre class="wiki"> SPT&lt;void&gt; // address shared ptr to single instance </pre><p> to </p> <pre class="wiki"> SPT&lt;const void&gt; // address shared ptr to single instance </pre><p> to regain previous behaviour (if one can check extensively). </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Wed, 29 Oct 2014 21:20:46 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/10488#comment:5 https://svn.boost.org/trac10/ticket/10488#comment:5 <ul> <li><strong>status</strong> <span class="trac-field-old">closed</span> → <span class="trac-field-new">reopened</span> </li> <li><strong>resolution</strong> <span class="trac-field-deleted">duplicate</span> </li> </ul> Ticket tonvandenheuvel@… Tue, 10 Feb 2015 15:10:34 GMT <link>https://svn.boost.org/trac10/ticket/10488#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:6</guid> <description> <p> I can confirm the fix proposed by reder works for me, although I have not checked this extensively. </p> </description> <category>Ticket</category> </item> <item> <author>chris@…</author> <pubDate>Thu, 12 Mar 2015 13:59:47 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10488#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:7</guid> <description> <p> This regression currently prevents building Cufflinks; the author is disinclined to work around the problem. I can't link the issue directly due to the spam trap, but google "cufflinks boost serialization". </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Thu, 12 Mar 2015 15:35:27 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10488#comment:8 https://svn.boost.org/trac10/ticket/10488#comment:8 <ul> <li><strong>status</strong> <span class="trac-field-old">reopened</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> note: already checked into master. Correction will appear in next boost release </p> Ticket boost@… Mon, 30 Mar 2015 04:08:54 GMT cc set https://svn.boost.org/trac10/ticket/10488#comment:9 https://svn.boost.org/trac10/ticket/10488#comment:9 <ul> <li><strong>cc</strong> <span class="trac-author">boost@…</span> added </li> </ul> <p> Which commit fixed this problem? I would like to try to backport it to boost 1.57.0 in <a class="missing wiki">MacPorts</a>. </p> Ticket boost@… Tue, 31 Mar 2015 00:39:14 GMT <link>https://svn.boost.org/trac10/ticket/10488#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:10</guid> <description> <p> I tested with boost 1.58.0 beta 1, released March 16, 2015, and the problem remains. </p> </description> <category>Ticket</category> </item> <item> <author>Mika Fischer <mika.fischer@…></author> <pubDate>Thu, 09 Apr 2015 09:02:17 GMT</pubDate> <title>cc changed https://svn.boost.org/trac10/ticket/10488#comment:11 https://svn.boost.org/trac10/ticket/10488#comment:11 <ul> <li><strong>cc</strong> <span class="trac-author">mika.fischer@…</span> added </li> </ul> Ticket boost@… Tue, 21 Apr 2015 18:10:12 GMT <link>https://svn.boost.org/trac10/ticket/10488#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:12</guid> <description> <p> I tested with boost 1.58.0, released April 17, 2015, and the problem remains. </p> <p> If the fix was supposed to be to change <code>SPT&lt;void&gt;</code> to <code>SPT&lt;const void&gt;</code> in <a class="ext-link" href="https://github.com/boostorg/serialization/blob/master/include/boost/serialization/shared_ptr_helper.hpp"><span class="icon">​</span>https://github.com/boostorg/serialization/blob/master/include/boost/serialization/shared_ptr_helper.hpp</a>, that has not occurred. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Fri, 24 Apr 2015 20:57:00 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10488#comment:13 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:13</guid> <description> <p> OK - I double checked - I fixed this again - I'm not sure what happened the first time </p> </description> <category>Ticket</category> </item> <item> <author>boost@…</author> <pubDate>Tue, 28 Apr 2015 21:43:39 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10488#comment:14 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:14</guid> <description> <p> Could you please post a link to the commit where you fixed it, so that I can backport it to boost 1.58.0 in <a class="missing wiki">MacPorts</a>? Thanks. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>xnox</dc:creator> <pubDate>Sun, 16 Aug 2015 10:25:09 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10488#comment:15 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:15</guid> <description> <p> Is this the fix for this issue? </p> <p> <a class="ext-link" href="https://github.com/boostorg/serialization/commit/010055816681a003a8090d105ea5ab385bb87bf8"><span class="icon">​</span>https://github.com/boostorg/serialization/commit/010055816681a003a8090d105ea5ab385bb87bf8</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Robert Ramey</dc:creator> <pubDate>Mon, 28 Sep 2015 06:17:12 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10488#comment:16 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10488#comment:16</guid> <description> <p> I believe so </p> </description> <category>Ticket</category> </item> </channel> </rss>