Boost C++ Libraries: Ticket #9718: boost::container::string assignment operator problem https://svn.boost.org/trac10/ticket/9718 <p> The following code compiles with std::string, but fails to with boost::container::string. The error message is: </p> <pre class="wiki">stringtest.cpp: In function ‘int main()’: stringtest.cpp:21:5: error: no match for ‘operator=’ (operand types are ‘Msg’ and ‘const Msg’) y = x; // ok with std::string, compilation error with boost::container::string ^ stringtest.cpp:21:5: note: candidate is: stringtest.cpp:7:8: note: Msg&amp; Msg::operator=(Msg&amp;) struct Msg ^ stringtest.cpp:7:8: note: no known conversion for argument 1 from ‘const Msg’ to ‘Msg&amp;’ </pre><p> ...which suggests the assignment operator generated for Msg takes only a Msg reference, not a const one. </p> <p> Boost 1.53.0 under Cygwin64, compiled using g++ (GCC) 4.8.1. </p> <pre class="wiki">#include &lt;string&gt; #include &lt;boost/container/string.hpp&gt; // using namespace std; using namespace boost::container; struct Msg { public: string msg; }; int main() { const string a("hello"); string b; b = a; // ok const Msg x; Msg y; y = x; // ok with std::string, compilation error with boost::container::string return 0; }; </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9718 Trac 1.4.3 viboes Wed, 26 Feb 2014 21:26:59 GMT component changed; owner set https://svn.boost.org/trac10/ticket/9718#comment:1 https://svn.boost.org/trac10/ticket/9718#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Ion Gaztañaga</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">container</span> </li> </ul> Ticket Piotr Sulecki <piotr.sulecki@…> Thu, 27 Feb 2014 09:27:33 GMT component changed https://svn.boost.org/trac10/ticket/9718#comment:2 https://svn.boost.org/trac10/ticket/9718#comment:2 <ul> <li><strong>component</strong> <span class="trac-field-old">container</span> → <span class="trac-field-new">None</span> </li> </ul> <p> Just checked: the code works ok when compiled in the C++11 mode (-std=c++11) but fails in the default mode (no -std specified, i.e. -std=c++03). </p> Ticket Ion Gaztañaga Thu, 27 Feb 2014 09:35:24 GMT <link>https://svn.boost.org/trac10/ticket/9718#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/9718#comment:3</guid> <description> <p> This is a well-known limitation of Boost.Move: </p> <p> <a href="http://www.boost.org/doc/libs/1_55_0/doc/html/move/emulation_limitations.html#move.emulation_limitations.assignment_operator">http://www.boost.org/doc/libs/1_55_0/doc/html/move/emulation_limitations.html#move.emulation_limitations.assignment_operator</a> </p> <p> However, it should be documented in the Container library as a known issue. I'll use this ticket for this. </p> <p> You'll need to define the assignment operator in the struct to workaround the issue. It's a pain but there is no fix for that. </p> </description> <category>Ticket</category> </item> <item> <author>Piotr Sulecki <piotr.sulecki@…></author> <pubDate>Thu, 27 Feb 2014 13:49:05 GMT</pubDate> <title>component changed https://svn.boost.org/trac10/ticket/9718#comment:4 https://svn.boost.org/trac10/ticket/9718#comment:4 <ul> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">container</span> </li> </ul> <p> Sorry about the component change, it was not intentional. Reverting it. </p> Ticket Ion Gaztañaga Fri, 13 Jun 2014 08:53:20 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9718#comment:5 https://svn.boost.org/trac10/ticket/9718#comment:5 <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> Documentation updated with this known issue in commit: </p> <p> SHA-1: 9c582e906aa95fa5a6d2383c8d4e4065ebdce160 </p> <ul><li>Documentation fixes: </li></ul><ul><li>allocator_traits was not properly placed in namespace boost::container </li><li>Fixed some typos </li><li>Added "Known Issues" section with move emulation problems. </li></ul> Ticket