title: Comparing std::minmax against a pair
body: <p>The standard algorithms <code>min</code> and <code>max</code> can be compared against a single value. However, the <code>minmax</code> algorithm return value cannot be compared against a pair of values: </p>
  
  <pre><code>#include &lt;algorithm&gt;
  #include &lt;utility&gt;
  
  template&lt;class T1, class T2&gt;
  constexpr auto make_cref_pair(T1&amp;&amp; t1, T2&amp;&amp; t2)
  {
      return std::pair&lt;T1 const&amp;, T2 const&amp;&gt;(std::forward&lt;T1&gt;(t1), std::forward&lt;T2&gt;(t2));
  }
  
  int main()
  {
      static_assert(std::min(2, 1) == 1); // OK
      static_assert(std::max(2, 1) == 2); // OK
      //static_assert(std::minmax(2, 1) == std::make_pair(1, 2)); // ERROR, const int&amp; vs int pair comparison
      static_assert(std::minmax(2, 1) == std::pair&lt;const int&amp;, const int&amp;&gt;(1, 2)); // OK
      static_assert(std::minmax(2, 1) == make_cref_pair(1, 2)); // OK
  }
  </code></pre>
  
  <p><a href="http://coliru.stacked-crooked.com/a/f1143ff935c4b0ab" rel="noreferrer"><strong>Live Example</strong></a></p>
  
  <p>The reason is that <code>make_pair(2, 1)</code> returns a <code>pair&lt;int, int&gt;</code> and <code>minmax(1, 2)</code> returns a <code>pair&lt;const int&amp;, const int&amp;&gt;</code>. There are no referenceness-mixing <code>operator==</code> overloads for <code>pair</code>. </p>
  
  <p>The fix is then to explicitly write <code>std::pair&lt;const int&amp;, const int&amp;&gt;(int, int)</code> or to wrap this in a home-made <code>make_cref_pair</code> function.</p>
  
  <p><strong>Questions</strong>: is there a cleaner way to compare the <code>minmax</code> return value against a <code>pair</code> of values? And did I correctly handle the references in my <code>make_cref_pair</code>?</p>