Boost C++ Libraries: Ticket #1842: boost::sub_rage::front error https://svn.boost.org/trac10/ticket/1842 <p> I think, there is an error in <em>sub_range::front const</em> method. It use <em>const value_type&amp;</em> instead of <em>const reference</em>. </p> <p> For example, here is a well compiled code, that fails on last assert, but should not: </p> <pre class="wiki">#include &lt;list&gt; #include &lt;boost/assign.hpp&gt; #include &lt;boost/assert.hpp&gt; #include &lt;boost/range/sub_range.hpp&gt; #include &lt;boost/iterator/transform_iterator.hpp&gt; //------------------------------------------------------------------------------ struct Trans: public std::unary_function&lt;int, int&gt; { int operator()(const int&amp; a)const { return a*2; } }; //------------------------------------------------------------------------------ int main(int argc, char* argv[]) { using namespace boost::assign; const std::list&lt;int&gt; a=list_of(10); const std::list&lt;int&gt; b=list_of(20); BOOST_ASSERT(!a.empty() &amp;&amp; !b.empty()); BOOST_ASSERT(a.front()!=b.front()); BOOST_ASSERT(Trans()(a.front())!=Trans()(b.front())); typedef boost::transform_iterator&lt;Trans, std::list&lt;int&gt;::const_iterator&gt; my_iter_t; typedef std::pair &lt; my_iter_t, my_iter_t &gt; my_pair_t; const boost::sub_range&lt;my_pair_t&gt; ar ( boost::make_transform_iterator(boost::const_begin(a), Trans()), boost::make_transform_iterator(boost::const_end(a), Trans()) ); const boost::sub_range&lt;my_pair_t&gt; br ( boost::make_transform_iterator(boost::const_begin(b), Trans()), boost::make_transform_iterator(boost::const_end(b), Trans()) ); BOOST_ASSERT(ar.front()!=br.front()); // &lt;---- fail return 0; } </pre> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/1842 Trac 1.4.3 Thorsten Ottosen Thu, 12 Jun 2008 10:00:28 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/1842#comment:1 https://svn.boost.org/trac10/ticket/1842#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> I've commputed the return value in a different manner now. Should fix your problem. </p> <p> -Thorsten </p> Ticket