title: Why should I avoid std::enable_if in function signatures
body: <p>Scott Meyers posted <a href="http://scottmeyers.blogspot.de/2013/01/effective-c11-content-and-status.html" rel="noreferrer">content and status</a> of his next book EC++11.
  He wrote that one item in the book could be <em>"Avoid <code>std::enable_if</code> in function signatures"</em>.</p>
  
  <p><code>std::enable_if</code> can be used as a function argument, as a return type or as a class template or function template parameter to conditionally remove functions or classes from overload resolution.</p>
  
  <p>In <a href="https://stackoverflow.com/questions/11055923/stdenable-if-parameter-vs-template-parameter">this question</a> all three solution are shown.</p>
  
  <p>As function parameter:</p>
  
  <pre><code>template&lt;typename T&gt;
  struct Check1
  {
     template&lt;typename U = T&gt;
     U read(typename std::enable_if&lt;
            std::is_same&lt;U, int&gt;::value &gt;::type* = 0) { return 42; }
  
     template&lt;typename U = T&gt;
     U read(typename std::enable_if&lt;
            std::is_same&lt;U, double&gt;::value &gt;::type* = 0) { return 3.14; }   
  };
  </code></pre>
  
  <p>As template parameter:</p>
  
  <pre><code>template&lt;typename T&gt;
  struct Check2
  {
     template&lt;typename U = T, typename std::enable_if&lt;
              std::is_same&lt;U, int&gt;::value, int&gt;::type = 0&gt;
     U read() { return 42; }
  
     template&lt;typename U = T, typename std::enable_if&lt;
              std::is_same&lt;U, double&gt;::value, int&gt;::type = 0&gt;
     U read() { return 3.14; }   
  };
  </code></pre>
  
  <p>As return type:</p>
  
  <pre><code>template&lt;typename T&gt;
  struct Check3
  {
     template&lt;typename U = T&gt;
     typename std::enable_if&lt;std::is_same&lt;U, int&gt;::value, U&gt;::type read() {
        return 42;
     }
  
     template&lt;typename U = T&gt;
     typename std::enable_if&lt;std::is_same&lt;U, double&gt;::value, U&gt;::type read() {
        return 3.14;
     }   
  };
  </code></pre>
  
  <ul>
  <li>Which solution should be preferred and why should I avoid others? </li>
  <li>In which cases <em>"Avoid <code>std::enable_if</code> in function signatures"</em> concerns usage as return type (which is not part of normal function signature but of template specializations)?</li>
  <li>Are there any differences for member and non-member function templates?</li>
  </ul>