Thank you all for your comments and diagnosis.<br>It sounds like I have to file a bug report to the boost developers.<br><br>Cheers,<br><br>Ryuta<br><br><div class="gmail_quote">On Sun, Jul 3, 2011 at 12:29 AM, Howard Hinnant <span dir="ltr"><<a href="mailto:hhinnant@apple.com">hhinnant@apple.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="im">On Jul 2, 2011, at 11:10 AM, Douglas Gregor wrote:<br>
<br>
><br>
> On Jul 1, 2011, at 7:55 PM, Eli Friedman wrote:<br>
><br>
>> On Fri, Jul 1, 2011 at 7:09 PM, ryuuta <<a href="mailto:ryuuta@gmail.com">ryuuta@gmail.com</a>> wrote:<br>
>>> Hi,<br>
>>> I bet the problem is in boost implementation but<br>
>>> I'm not 100% sure whether the issue is really on boost side or not.<br>
</div><snip><br>
<div class="im">>> Testcase without boost:<br>
>><br>
>> #include <map><br>
>> struct A { int& x; explicit A(int); public: bool operator<(const A&<br>
>> other) const {return x < other.x; }};<br>
>> void f(A* x) { std::map<A, int> y, z; z = y; }<br>
>><br>
>> This looks like a boost bug to me... as far as I can tell, the Key<br>
>> type of an std::map is required to be assignable if you're assigning<br>
>> one map to another (although the implementation isn't required to<br>
>> actually use that assignment operator).<br>
><br>
><br>
> C++0x [container.requirements.general] is fairly clear that assigning a container requires the element type to be move assignable. This is a Boost bug.<br>
<br>
</div>Strongly agree.  Especially if you s/copy/move. ;-)  And include the reference [associative.reqmts]/p7:<br>
<br>
>  The associative containers meet all the requirements of Allocator-aware containers (23.2.1), except that for map and multimap, the requirements placed on value_type in Table 96 apply instead to key_type and mapped_type. [Note: For example, in some cases key_type and mapped_type are required to be CopyAssignable even though the associated value_type, pair<const key_type, mapped_type>, is not CopyAssignable. —endnote]<br>

<br>
<br>
To be fair to boost, this was at best unspecified in C++03 and no implementation of map took advantage of it (erase/insert was/is a common algorithm for assignment).  libc++ is probably the first std::lib to recycle nodes under associative container assignment.  This can be a huge performance win for copy assignment.<br>

<br>
Howard<br>
<br>
<br>
_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</blockquote></div><br>