Reformulate custom predicate as std-predicate
<p>A program I'm working on contains this predicate struct:</p>

<pre><code>struct Unlike {
    Unlike(const Vertex&amp; in) : a(in) {}
    bool operator()(const Vertex&amp; b) {
        return !(a==b);
    }
    const Vertex&amp; a;
};
</code></pre>

<p>Vertices are structs with (among other members) a struct coord with members X, Y, Z. Comparison is done with these functions:</p>

<pre><code>bool operator==(const Vertex&amp; a, const Vertex&amp; b) {
    bool res =  a.coord.X == b.coord.X &amp;&amp;
        a.coord.Y == b.coord.Y &amp;&amp;
        a.coord.Z == b.coord.Z;
    return res;
}
inline bool operator!=(const Vertex&amp; a, const Vertex&amp; b) {
    bool res = !(a==b);
    return res;
}
</code></pre>

<p>Which is used like this:</p>

<pre><code>std::vector&lt;Vertex&gt; vertices;
// Fill and sort vertices
std::vector&lt;Vertex&gt;::iterator vcur, vnext;
vcur = vertices.begin();
while(vcur != vertices.end()) {
    vnext = std::find_if(vcur, vertices.end(), Unlike(*vcur));
    // Loop over [vcur, vnext]
    vcur = vnext;
}
</code></pre>

<p>So we perform some calculations on all vertices which compare equal.</p>

<p>I'm doing some cleaning in the code, and would like to get rid of the <code>Unlike</code> struct. I tried to do it like this, which to my mind is clearer in intent:</p>

<pre><code>vnext = std::adjacent_find(vcur, vertices.end(), std::not_equal_to&lt;Vertex&gt;());
</code></pre>

<p>but that did not retain the same behavior, but rather goes into an infinite loop. Why? Have I misinterpreted <code>adjacent_find</code> or <code>not_equal_to</code>?</p>
