Compilation error when trying to find_if an unique_ptr in a vector
<p>This code:</p>

<pre><code>#include &lt;memory&gt;
#include &lt;vector&gt;
#include &lt;algorithm&gt;

struct Foo
{
    int bar;

    Foo(const int val) :
        bar(val)
    {
    }
};

int main() {
    std::vector&lt;std::unique_ptr&lt;Foo&gt;&gt; vec;
    vec.emplace_back(std::make_unique&lt;Foo&gt;(42));
    Foo* ptr = vec.back().get();
    auto&amp; it = std::find_if(vec.begin(), vec.end(), [&amp;](std::unique_ptr&lt;Foo&gt;&amp; p)
    {
        return p.get() == ptr;
    });
    if (it != vec.end())
    {
        vec.erase(it);
    }

    return 0;
}
</code></pre>

<p>Works fine in MSVC, but errors out in GCC 5.1:</p>

<blockquote>
  <p>prog.cpp: In function 'int main()':</p>
  
  <p>prog.cpp:19:25: error: invalid initialization of non-const reference of type '__gnu_cxx::__normal_iterator*, std::vector > >&amp;' from an rvalue of type '__gnu_cxx::__normal_iterator*, std::vector > >'
    auto&amp; it = std::find_if(vec.begin(), vec.end(), [&amp;](std::unique_ptr&amp; p)</p>
</blockquote>

<ol>
<li>Which compiler is bugged?</li>
<li>How do I erase a pointer from a <code>std::vector</code> of <code>std::unique_ptr</code> correctly?</li>
</ol>