title: How to make this boost::enable_if code compile (SFINAE)?
body: <p>I'm puzzled why the following code that uses <code>boost::enable_if</code> doesn't compile. It checks if type <code>T</code> has a member function <code>hello</code> and calls it if that's the case:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/utility/enable_if.hpp&gt;
  #include &lt;boost/static_assert.hpp&gt;
  
  // Has_hello&lt;T&gt;::value is true if T has a hello function.
  template&lt;typename T&gt;
  struct has_hello {
    typedef char yes[1];
    typedef char no [2];
    template &lt;typename U&gt; struct type_check;
    template &lt;typename U&gt; static yes &amp;chk(type_check&lt;char[sizeof(&amp;U::hello)]&gt; *);
    template &lt;typename  &gt; static no  &amp;chk(...);
    static const bool value = sizeof(chk&lt;T&gt;(0)) == sizeof(yes);
  };
  
  template&lt;typename T&gt;
  void doSomething(T const&amp; t,
                   typename boost::enable_if&lt;typename has_hello&lt;T&gt;::value&gt;::type* = 0
                   ) {
    return t.hello();
  }
  
  // Would need another doSomething` for types that don't have hello().
  
  struct Foo {
    void hello() const {
      std::cout &lt;&lt; "hello" &lt;&lt; std::endl;
    }
  };
  
  // This check is ok:
  BOOST_STATIC_ASSERT(has_hello&lt;Foo&gt;::value);
  
  int main() {
    Foo foo;
    doSomething&lt;Foo&gt;(foo);
  }
  </code></pre>
  
  <p>I'm getting </p>
  
  <pre><code>no matching function for call to ‘doSomething(Foo&amp;)
  </code></pre>
  
  <p>with <code>gcc 4.4.4</code>.</p>
  
  <p>The static assert is ok, so <code>has_hello&lt;Foo&gt;::value</code> is indeed <code>true</code>. Am I using <code>boost::enable_if</code> wrong?</p>