title: How do I use std::enable_if with a self-deducing return type?
body: <p><a href="http://en.wikipedia.org/wiki/C++14#Function_return_type_deduction" rel="noreferrer">C++14</a> will have functions whose return type can be deduced based on the return value.  </p>
  
  <pre><code>auto function(){
      return "hello world";
  }
  </code></pre>
  
  <p>Can I apply this behaviour to functions that use <a href="http://en.cppreference.com/w/cpp/types/enable_if" rel="noreferrer">enable_if</a> for the SFINAE by return type idiom?</p>
  
  <p>For example, let's consider the following two functons:</p>
  
  <pre><code>#include &lt;type_traits&gt;
  #include &lt;iostream&gt;
  
  //This function is chosen when an integral type is passed in
  template&lt;class T &gt;
  auto function(T t) -&gt; typename std::enable_if&lt;std::is_integral&lt;T&gt;::value&gt;::type {
      std::cout &lt;&lt; "integral" &lt;&lt; std::endl;
      return;
  }
  
  //This function is chosen when a floating point type is passed in
  template&lt;class T &gt;
  auto function(T t) -&gt; typename std::enable_if&lt;std::is_floating_point&lt;T&gt;::value&gt;::type{
      std::cout &lt;&lt; "floating" &lt;&lt; std::endl;
      return;
  }
  
  int main(){
  
    function(1);    //prints "integral"
    function(3.14); //prints "floating"
  
  }
  </code></pre>
  
  <p>As you can see, the correct function is chosen using the SFINAE by return type idiom.
  However, these are both void functions.  The second parameter of <code>enable_if</code> is default set to <code>void</code>. This would be the same:</p>
  
  <pre><code>//This function is chosen when an integral type is passed in
  template&lt;class T &gt;
  auto function(T t) -&gt; typename std::enable_if&lt;std::is_integral&lt;T&gt;::value, void&gt;::type {
      std::cout &lt;&lt; "integral" &lt;&lt; std::endl;
      return;
  }
  
  //This function is chosen when a floating point type is passed in
  template&lt;class T &gt;
  auto function(T t) -&gt; typename std::enable_if&lt;std::is_floating_point&lt;T&gt;::value, void&gt;::type{
      std::cout &lt;&lt; "floating" &lt;&lt; std::endl;
      return;
  }
  </code></pre>
  
  <p>Is there something I can do to these two functions, so that their return type is deduced by the return value?</p>
  
  <p>gcc 4.8.2 (using <code>--std=c++1y</code>)</p>