Boost C++ Libraries: Ticket #13456: Object tracking fails with pointer to variant's content https://svn.boost.org/trac10/ticket/13456 <p> Object tracking fails with a pointer to an object contained into a variant that is an element of a container which loads the value_type into a local object. For example a map with a variant as a mapped_type. </p> <p> There is a pull request: <a class="ext-link" href="https://github.com/boostorg/serialization/pull/96"><span class="icon">​</span>https://github.com/boostorg/serialization/pull/96</a> </p> <p> Demo: </p> <pre class="wiki">struct Foo { int i; template&lt;typename Archive&gt; void serialize(Archive&amp; ar, const unsigned int version) { ar &amp; i; } }; int main() { using map_t = std::unordered_map&lt;std::string, boost::variant&lt;Foo, float&gt;&gt;; std::string testfile{"/tmp/serialized"}; { map_t map{{"key", Foo{5}}}; auto ptr = &amp;boost::strict_get&lt;Foo&gt;(map.begin()-&gt;second); std::ofstream os(testfile); boost::archive::text_oarchive oa(os); oa &lt;&lt; map; oa &lt;&lt; ptr; } { std::ifstream is(testfile, (std::ios_base::openmode)0); boost::archive::text_iarchive ia(is, 0); map_t map; Foo* ptr; ia &gt;&gt; map; ia &gt;&gt; ptr; assert(ptr-&gt;i == 5); } } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13456 Trac 1.4.3 Ricardo Calheiros de Miranda Cosme <ricardo.cosme@…> Sat, 24 Feb 2018 14:07:05 GMT attachment set https://svn.boost.org/trac10/ticket/13456 https://svn.boost.org/trac10/ticket/13456 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">bug_serialization_variant.tgz</span> </li> </ul> <p> Demo </p> Ticket Ricardo Calheiros de Miranda Cosme <ricardo.cosme@…> Sat, 24 Feb 2018 14:07:35 GMT version changed https://svn.boost.org/trac10/ticket/13456#comment:1 https://svn.boost.org/trac10/ticket/13456#comment:1 <ul> <li><strong>version</strong> <span class="trac-field-old">Boost 1.63.0</span> → <span class="trac-field-new">Boost Development Trunk</span> </li> </ul> Ticket Ricardo Calheiros de Miranda Cosme <ricardo.cosme@…> Sat, 24 Feb 2018 14:50:15 GMT <link>https://svn.boost.org/trac10/ticket/13456#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13456#comment:2</guid> <description> <p> Sorry, my pull request(<a class="closed ticket" href="https://svn.boost.org/trac10/ticket/96" title="#96: Tasks: Finish target paths (closed: fixed)">#96</a>) does not compile at some platforms. I will fix this. </p> </description> <category>Ticket</category> </item> <item> <author>Ricardo Calheiros de Miranda Cosme <ricardo.cosme@…></author> <pubDate>Sun, 25 Feb 2018 02:22:03 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13456#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13456#comment:3</guid> <description> <p> Pull request with a bugfix proposal <a class="ext-link" href="https://github.com/boostorg/serialization/pull/98"><span class="icon">​</span>https://github.com/boostorg/serialization/pull/98</a> </p> </description> <category>Ticket</category> </item> </channel> </rss>