Boost C++ Libraries: Ticket #13203: adjacent_filtered lets the first element entry through https://svn.boost.org/trac10/ticket/13203 <p> <code>adjacent_filtered</code> always lets the first element of the range leak through, even for a predicate that rejects that element as either argument. Eg. </p> <div class="wiki-code"><div class="code"><pre><span class="kt">int</span> <span class="nf">main</span><span class="p">()</span> <span class="p">{</span> <span class="k">const</span> <span class="n">std</span><span class="o">::</span><span class="n">vector</span><span class="o">&lt;</span><span class="kt">int</span><span class="o">&gt;</span> <span class="n">a</span> <span class="o">=</span> <span class="p">{</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">,</span> <span class="mi">4</span><span class="p">,</span> <span class="mi">5</span> <span class="p">};</span> <span class="k">auto</span> <span class="n">b</span> <span class="o">=</span> <span class="n">a</span> <span class="o">|</span> <span class="n">boost</span><span class="o">::</span><span class="n">adaptors</span><span class="o">::</span><span class="n">adjacent_filtered</span><span class="p">(</span> <span class="p">[]</span> <span class="p">(</span><span class="k">const</span> <span class="kt">int</span> <span class="o">&amp;</span><span class="n">x</span><span class="p">,</span> <span class="k">const</span> <span class="kt">int</span> <span class="o">&amp;</span><span class="n">y</span><span class="p">)</span> <span class="p">{</span> <span class="k">return</span> <span class="p">(</span> <span class="p">(</span> <span class="n">x</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="p">)</span> <span class="o">&amp;&amp;</span> <span class="p">(</span> <span class="n">y</span> <span class="o">&gt;</span> <span class="mi">2</span> <span class="p">)</span> <span class="p">);</span> <span class="p">}</span> <span class="p">);</span> <span class="k">for</span> <span class="p">(</span><span class="k">const</span> <span class="k">auto</span> <span class="o">&amp;</span><span class="nl">x</span> <span class="p">:</span> <span class="n">b</span><span class="p">)</span> <span class="p">{</span> <span class="n">std</span><span class="o">::</span><span class="n">cerr</span> <span class="o">&lt;&lt;</span> <span class="n">x</span> <span class="o">&lt;&lt;</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">;</span> <span class="p">}</span> <span class="p">}</span> </pre></div></div><p> …outputs: </p> <pre class="wiki">0 4 5 </pre><p> From what I can see in the code, the predicate is currently only applied in the <code>increment()</code> function, which leaves it too late for the first element to be checked. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13203 Trac 1.4.3