Boost C++ Libraries: Ticket #7969: BOOST_MOVABLE_BUT_NOT_COPYABLE makes it impossible to use type in GCC containners in C++11 https://svn.boost.org/trac10/ticket/7969 <p> BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE) defines: </p> <p> TYPE(const TYPE &amp;); TYPE&amp; operator=(const TYPE &amp;); </p> <p> which makes GCC assume that class have copy constructor and assignment operator. That makes STL containers to choose assignment operator instead of move assignment. </p> <p> The solution would be to mark them in c++11 with '= delete' or not write them at all (compiler shall not generate copy constructors if there is a move constructor, but this may not work on some compilers): </p> <pre class="wiki">#ifndef BOOST_NO_CXX11_DELETED_FUNCTIONS #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ public:\ typedef int boost_move_emulation_t;\ private:\ TYPE(const TYPE &amp;) = delete;\ TYPE&amp; operator=(const TYPE &amp;) = delete;\ #else #define BOOST_MOVABLE_BUT_NOT_COPYABLE(TYPE)\ public:\ typedef int boost_move_emulation_t;\ private:\ #endif </pre><p> Example to reproduce the error: </p> <pre class="wiki">#include &lt;boost/move/move.hpp&gt; #include &lt;vector&gt; class descriptor_owner_movable { void* descriptor_; BOOST_MOVABLE_BUT_NOT_COPYABLE(descriptor_owner_movable) public: descriptor_owner_movable(){} descriptor_owner_movable(BOOST_RV_REF(descriptor_owner_movable) param) {} descriptor_owner_movable&amp; operator=(BOOST_RV_REF(descriptor_owner_movable) param) { return *this; } }; int main() { std::vector&lt;descriptor_owner_movable&gt; vec; vec.resize(10); return 0; } </pre><p> Tested on GCC 4.7.2 with -std=c++0x flag </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/7969 Trac 1.4.3 viboes Sun, 03 Feb 2013 18:44:19 GMT <link>https://svn.boost.org/trac10/ticket/7969#comment:1 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7969#comment:1</guid> <description> <p> Ion, in case this could help, Boost.Thread contains already a boost/thread/detail/delete.hpp file defining BOOST_THREAD_NO_COPYABLE that could help you. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Sun, 03 Feb 2013 20:42:28 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7969#comment:2 https://svn.boost.org/trac10/ticket/7969#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/82706" title="Fixes #7969">[82706]</a>) Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7969" title="#7969: Bugs: BOOST_MOVABLE_BUT_NOT_COPYABLE makes it impossible to use type in GCC ... (closed: fixed)">#7969</a> </p> Ticket Ion Gaztañaga Sun, 03 Feb 2013 20:45:12 GMT <link>https://svn.boost.org/trac10/ticket/7969#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7969#comment:3</guid> <description> <p> Thanks for the report and hint. Let me know if the patch fixes the issue. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 03 Feb 2013 22:23:37 GMT</pubDate> <title>status changed; resolution deleted https://svn.boost.org/trac10/ticket/7969#comment:4 https://svn.boost.org/trac10/ticket/7969#comment:4 <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">fixed</span> </li> </ul> <p> Ion, IIRC your macros were expected to be included on the private part. </p> <pre class="wiki"> Put the following macro in the private section: BOOST_MOVABLE_BUT_NOT_COPYABLE(classname) </pre><p> After the change (line 224) BOOST_MOVABLE_BUT_NOT_COPYABLE stay in the public part. This should be fixed. </p> Ticket Ion Gaztañaga Mon, 04 Feb 2013 05:41:43 GMT <link>https://svn.boost.org/trac10/ticket/7969#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/7969#comment:5</guid> <description> <p> Let's see if <a class="changeset" href="https://svn.boost.org/trac10/changeset/82711" title="Fixes #7969">[82711]</a> definitely fixes it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Ion Gaztañaga</dc:creator> <pubDate>Thu, 14 Feb 2013 17:33:41 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/7969#comment:6 https://svn.boost.org/trac10/ticket/7969#comment:6 <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> Reported in the boost mailing list that GCC 4.7.2 works fine now. </p> Ticket