Boost C++ Libraries: Ticket #5711: Equality of unordered containers violates Library requirements https://svn.boost.org/trac10/ticket/5711 <p> Both unordered sets and maps have operator==/!= implementations that violate the Library requirements of unordered containers. The following program makes this observable: </p> <pre class="wiki">#include &lt;iostream&gt; #include &lt;cstring&gt; #include &lt;boost/unordered_set.hpp&gt; struct CharIC { bool operator()(char c1, char c2) const { return std::toupper(c1) == std::toupper(c2); } std::size_t operator()(char c) const { return std::toupper(c); } }; int main() { boost::unordered_set&lt;char, CharIC, CharIC&gt; us1, us2; us1.insert('a'); us2.insert('A'); std::cout &lt;&lt; "us1 == us1: " &lt;&lt; (us1 == us1) &lt;&lt; std::endl; std::cout &lt;&lt; "us1 != us2: " &lt;&lt; (us1 != us2) &lt;&lt; std::endl; } </pre><p> The second output is: </p> <p> us1 != us2: 0 </p> <p> instead of the expected </p> <p> us1 != us2: 1 </p> <p> Reason for this deviation is that the current boost implementation does not additionally test for equality of the container key (which is the value_type for sets). But this is required as of FDIS, [unord.req] p11, where the semantics is defined in terms of the form of std::is_permutation that uses operator== of the iterator value_type. The proper usage of the key equality test is part of the reference implementation of N3068 as well. As far as I read boost/unordered/detail/equivalent.hpp correctly, the same defect applies to the non-unique containers. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5711 Trac 1.4.3 anonymous Mon, 18 Jul 2011 23:04:48 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/5711#comment:1 https://svn.boost.org/trac10/ticket/5711#comment:1 <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> This is fixed on trunk. The equality implementation in the released version predates the specification, which is why it doesn't follow it. </p> Ticket