Boost C++ Libraries: Ticket #9515: [range] uniqued adaptor (and hence adjacent_filtered) returns wrong elements https://svn.boost.org/trac10/ticket/9515 <p> The following shows the difference between the <code>boost::range::unique_copy</code> algorithm and the <code>boost::adaptors::unique</code> adaptor. </p> <pre class="wiki">#include &lt;string&gt; #include &lt;vector&gt; #include &lt;iterator&gt; #include &lt;iostream&gt; #include &lt;boost/algorithm/string.hpp&gt; #include &lt;boost/range/algorithm/copy.hpp&gt; #include &lt;boost/range/algorithm/unique_copy.hpp&gt; #include &lt;boost/range/adaptor/uniqued.hpp&gt; struct istring { char const *c_str; istring(char const *s) : c_str(s) {} bool operator==(istring u) const { return boost::iequals(c_str, u.c_str); } friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp; sout, istring s) { return sout &lt;&lt; s.c_str; } }; int main() { std::vector&lt;istring&gt; strs; strs.push_back(istring("hello")); strs.push_back(istring("HELLO")); std::cout &lt;&lt; "boost.range: \n"; boost::range::copy( boost::adaptors::unique(strs), std::ostream_iterator&lt;istring&gt;(std::cout)); std::cout &lt;&lt; "\n"; std::cout &lt;&lt; "std algo: \n"; boost::range::unique_copy(strs, std::ostream_iterator&lt;istring&gt;(std::cout)); std::cout &lt;&lt; "\n"; } </pre><p> This prints: </p> <pre class="wiki">boost.range: HELLO std algo: hello </pre><p> <code>std::unique</code> and <code>std::unique_copy</code> yield the *first* element in a sequence of equivalent elements. The Boost adaptor yields the last. This is an important and observable difference. </p> <p> Since <code>uniqued</code> is implemented in terms of <code>adjacent_filtered</code>, the problem needs to be fixed there. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/9515 Trac 1.4.3 Michel Morin Thu, 26 Dec 2013 22:44:26 GMT component changed; owner set https://svn.boost.org/trac10/ticket/9515#comment:1 https://svn.boost.org/trac10/ticket/9515#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Neil Groves</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">range</span> </li> </ul> Ticket Neil Groves Fri, 21 Feb 2014 20:30:25 GMT status changed https://svn.boost.org/trac10/ticket/9515#comment:2 https://svn.boost.org/trac10/ticket/9515#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> </ul> Ticket Neil Groves Mon, 03 Mar 2014 01:25:25 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/9515#comment:3 https://svn.boost.org/trac10/ticket/9515#comment:3 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> Ticket