title: Cannot use user-provided comparison function for std::set<std::string, std::less<>>
body: <p>I stumbled upon very strange compile error for <code>std::set</code> using transparent comparators with help of <code>std::less</code>. Consider this simple program:</p>
  
  <pre><code>using Key = std::string;
  
  bool operator&lt;(const Key&amp;, int) { return true; }
  bool operator&lt;(int, const Key&amp;) { return true; }
  
  int main()
  {
    std::set&lt;Key, std::less&lt;&gt;&gt; s;
    int x;
    auto it = s.find(x);
  }
  </code></pre>
  
  <p>It gives me compile error:</p>
  
  <pre><code>error: no matching function for call to object of type 'const std::less&lt;void&gt;'
        if (__j != end() &amp;&amp; _M_impl._M_key_compare(__k, _S_key(__j._M_node)))
                            ^~~~~~~~~~~~~~~~~~~~~~
  </code></pre>
  
  <p>If I use my own class instead of <code>std::string</code> as a key, it works fine:</p>
  
  <pre><code>struct My {};
  bool operator&lt;(const My&amp;, const My&amp;) { return true; }
  
  using Key = My;
  </code></pre>
  
  <p>Why it does not work for <code>std::string</code>?</p>
  
  <p>See the demo here: <a href="https://gcc.godbolt.org/z/MY-Y2s" rel="nofollow noreferrer">https://gcc.godbolt.org/z/MY-Y2s</a></p>
  
  <p><strong>UPD</strong></p>
  
  <p>What I really wanted to do, is to declare comparison operators between <code>std::unique_ptr&lt;T&gt;</code> and <code>T*</code>. But I thought it would be clearer with <code>std::string</code>.</p>