title: Can't make my example using std::ranges::copy_if(R&& r, O result, Pred pred, Proj proj = {}) compile
body: <p>I've reduced the code failing to compile to the one below:</p>
  <p><a href="https://godbolt.org/z/fsE363jzs" rel="nofollow noreferrer">[Demo]</a></p>
  <pre class="lang-cpp prettyprint-override"><code>#include &lt;algorithm&gt;  // copy_if
  #include &lt;iostream&gt;  // cout
  #include &lt;iterator&gt;  // back_inserter
  #include &lt;ranges&gt;
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  struct A
  {
      std::string p{};
      std::string d{};
  };
  
  int main()
  {
      std::vector&lt;A&gt; v{{&quot;/usr/bin/cat&quot;, &quot;blah&quot;}, {&quot;/usr/lib&quot;, &quot;foo&quot;}};
      std::vector&lt;std::string&gt; o{};
      std::ranges::copy_if(
          v,
          std::back_inserter(o),
          [](std::string&amp; p){ return (p.size() &gt; 10); },
          &amp;A::p);
  }
  </code></pre>
  <p>Visual Studio's error output is quite short: <code>error C7602: 'std::ranges::_Copy_if_fn::operator ()': the associated constraints are not satisfied.</code> It basically points you to check the constraints of <code>copy_if</code> at the <code>algorithm</code> header.</p>
  <p>gcc and clang are more detailed. Having a look at a bit of both outputs:</p>
  <ul>
  <li>First, the <code>copy_if</code> overload with a range, an output iterator, a predicate, and a projection, is considered.</li>
  <li>But then, the expression <code>*__o = (std::forward&lt;_Tp&gt;(__t)</code> is evaluated as invalid; where: <code>'_Out&amp;&amp; __o', '_Tp&amp;&amp; __t' [with _Tp = A&amp;; _Out = std::back_insert_iterator&lt;std::vector&lt;std::string&gt;&gt;]</code></li>
  </ul>
  <p>Since we are using a projection (from <code>A&amp;</code> to <code>std::string&amp;</code>), why is it trying to copy an <code>A&amp;</code> instead of a <code>std::string&amp;</code> to <code>o</code>?</p>
  <p>The full error output is accessible through the Demo link above.</p>