Using lambda on lower_bound
<p>I am trying to use lambda on lower_bound in c++. I have defined a struct</p>

<pre><code>struct Mop{
    Mop( string n, int a){
        name = n;
        age  = a;
    }
    string name;
    int     age;
    bool operator &lt; ( const Mop&amp;a) const {
        return age &lt; a.age;
    }
};
</code></pre>

<p>and add function</p>

<pre><code>void AddVector(vector&lt;Mop&gt; &amp;a, string n , int aa){
    Mop mop(n,aa);
    auto it = lower_bound(a.begin(), a.end(), aa , [](const Mop &amp;ar, const Mop &amp;br){ return ar &lt; br;});
    a.insert(mop,it);
}
int main()
{
    vector&lt;Mop&gt; a;
    AddVector(a,"John",15);
    AddVector(a,"Swan",10);
    return 0;
}
</code></pre>

<p>But it keep throwing error regarding lambda :</p>

<pre><code>error: no matching function for call to 'lower_bound(std::vector&lt;Mop&gt;::iterator, std::vector&lt;Mop&gt;::iterator, int&amp;, AddVector(std::vector&lt;Mop&gt;&amp;, std::string, int)::__lambda0)'
</code></pre>

<p>I have been searching and the lambda syntax should be corect , why does it keep throwing the error? I tried adding</p>

<pre><code>ar.age and br.age
</code></pre>

<p>to lambda didn't work either.</p>

<p>Whats wrong this lambda?</p>