Boost C++ Libraries: Ticket #5944: Compiler error when primitive type for data used https://svn.boost.org/trac10/ticket/5944 <p> This doesn't compile because the primitive type <em>int</em> is used as a second template parameter: </p> <div class="wiki-code"><div class="code"><pre><span class="n">boost</span><span class="o">::</span><span class="n">property_tree</span><span class="o">::</span><span class="n">basic_ptree</span><span class="o">&lt;</span><span class="n">std</span><span class="o">::</span><span class="n">string</span><span class="p">,</span> <span class="kt">int</span><span class="o">&gt;</span> <span class="n">pt</span><span class="p">,</span> <span class="n">pt2</span><span class="p">;</span> <span class="n">pt</span><span class="p">.</span><span class="n">swap</span><span class="p">(</span><span class="n">pt2</span><span class="p">);</span> </pre></div></div><p> The reason is this code in version 1.47.0 of &lt;<a class="ext-link" href="http://svn.boost.org/svn/boost/trunk/boost/property_tree/detail/ptree_implementation.hpp"><span class="icon">​</span>http://svn.boost.org/svn/boost/trunk/boost/property_tree/detail/ptree_implementation.hpp</a>&gt;: </p> <div class="wiki-code"><div class="code"><pre><span class="kt">void</span> <span class="n">basic_ptree</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">C</span><span class="o">&gt;::</span><span class="n">swap</span><span class="p">(</span><span class="n">basic_ptree</span><span class="o">&lt;</span><span class="n">K</span><span class="p">,</span> <span class="n">D</span><span class="p">,</span> <span class="n">C</span><span class="o">&gt;</span> <span class="o">&amp;</span><span class="n">rhs</span><span class="p">)</span> <span class="p">{</span> <span class="n">m_data</span><span class="p">.</span><span class="n">swap</span><span class="p">(</span><span class="n">rhs</span><span class="p">.</span><span class="n">m_data</span><span class="p">);</span> <span class="c1">// Void pointers, no ADL necessary</span> <span class="n">std</span><span class="o">::</span><span class="n">swap</span><span class="p">(</span><span class="n">m_children</span><span class="p">,</span> <span class="n">rhs</span><span class="p">.</span><span class="n">m_children</span><span class="p">);</span> <span class="p">}</span> </pre></div></div><p> m_data.swap() should be replaced with std::swap() or boost::swap() to make it possible to use primitive types for data. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5944 Trac 1.4.3 Sebastian Redl Tue, 04 Oct 2011 11:11:53 GMT <link>https://svn.boost.org/trac10/ticket/5944#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5944#comment:1</guid> <description> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/74691" title="Use boost::swap for swapping PTree's data member. Makes it possible to ...">[74691]</a>) Use boost::swap for swapping PTree's data member. Makes it possible to use types as data that don't provide a member swap(). See bug 5944. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Sebastian Redl</dc:creator> <pubDate>Fri, 13 Jan 2012 12:20:43 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5944#comment:2 https://svn.boost.org/trac10/ticket/5944#comment:2 <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">fixed</span> </li> </ul> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/76447" title="Merge [72000],[72001],[72003], [74691], [75587], [75589], [75590], and ...">[76447]</a>) Merge <a class="changeset" href="https://svn.boost.org/trac10/changeset/72000" title="Make PTree XML writer escape attribute values.">[72000]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/72001" title="Allow nuls in PTree XML. See bug 5259.">[72001]</a>,<a class="changeset" href="https://svn.boost.org/trac10/changeset/72003" title="Try to work around MSVC name lookup bug. See bug 5281.">[72003]</a>, <a class="changeset" href="https://svn.boost.org/trac10/changeset/74691" title="Use boost::swap for swapping PTree's data member. Makes it possible to ...">[74691]</a>, <a class="changeset" href="https://svn.boost.org/trac10/changeset/75587" title="Give string_path an accessor for the separator.">[75587]</a>, <a class="changeset" href="https://svn.boost.org/trac10/changeset/75589" title="Make ptree_bad_data::data() and ptree_bad_path::path() const. See bug ...">[75589]</a>, <a class="changeset" href="https://svn.boost.org/trac10/changeset/75590" title="Suppress the MSVC insecure warning when compiling tests. Make ...">[75590]</a>, and <a class="changeset" href="https://svn.boost.org/trac10/changeset/75593" title="Improve pair member bug workaround: should now hopefully work with ...">[75593]</a> from trunk. Fixes bug 4840. Fixes bug 5259. Fixes bug 5281, I think. Fixes bug 5944. Fixes bug 5757. Fixes bug 5710. Fixes bug 5307, I think. </p> Ticket