title: Why can template instances not be deduced in `std::reference_wrapper`s?
body: <p>Suppose I have some object of type <code>T</code>, and I want to put it into a reference wrapper:</p>
  
  <pre><code>int a = 5, b = 7;
  
  std::reference_wrapper&lt;int&gt; p(a), q(b);   // or "auto p = std::ref(a)"
  </code></pre>
  
  <p>Now I can readily say <code>if (p &lt; q)</code>, because the reference wrapper has a conversion to its wrapped type. All is happy, and I can process a collection of reference wrappers just like they were the original objects.</p>
  
  <p><sub>(As the <a href="https://stackoverflow.com/a/8512759/596781">question linked below</a> shows, this can be a useful way to produce an alternate view of an existing collection, which can be rearranged at will without incurring the cost of a full copy, as well as maintaining update integrity with the original collection.)</sub></p>
  
  <p><br></p>
  
  <p>However, with some classes this doesn't work:</p>
  
  <pre><code>std::string s1 = "hello", s2 = "world";
  
  std::reference_wrapper&lt;std::string&gt; t1(s1), t2(s2);
  
  return t1 &lt; t2;  // ERROR
  </code></pre>
  
  <p>My workaround is to define a predicate <s>as in <a href="https://stackoverflow.com/a/8512759/596781">this answer</a></s>*; but my question is:</p>
  
  <p>Why and when can operators be applied to reference wrappers and transparently use the operators of the wrapped types? Why does it fail for <code>std::string</code>? What has it got to do with the fact that <code>std::string</code> is a template instance?</p>
  
  <p>*) Update: In the light of the answers, it seems that using <code>std::less&lt;T&gt;()</code> is a general solution.</p>