title: Is the "lazy man's enable_if" legal C++?
body: <p>I frequently use a technique I call the "lazy man's <code>enable_if</code>," where I use <code>decltype</code> and the comma operator to enable a function based on some template input. Here is a small example:</p>
  
  <pre><code>template &lt;typename F&gt;
  auto foo(F&amp;&amp; f) -&gt; decltype(f(0), void())
  {
      std::cout &lt;&lt; "1" &lt;&lt; std::endl;
  }
  
  template &lt;typename F&gt;
  auto foo(F&amp;&amp; f) -&gt; decltype(f(0, 1), void())
  {
      std::cout &lt;&lt; "2" &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>With <code>--std=c++11</code>, g++ 4.7+ and Clang 3.5+ happily compile that bit of code (and it works as I would expect). However, when using MSVC 14 CTP5, I get this error complaining of <code>foo</code> already being defined:</p>
  
  <blockquote>
    <p>Error error C2995: 'unknown-type foo(F &amp;&amp;)': function template has
    already been defined  c++-scratch main.cpp    15</p>
  </blockquote>
  
  <p>So my question is: Is the "lazy man's <code>enable_if</code>" legal C++ or is this an MSVC bug?</p>