title: Determine whether a class has a function
body: <p>Using a trick (described by <a href="http://blog.olivierlanglois.net/index.php/2007/09/01/what_is_the_c_sfinae_principle" rel="nofollow noreferrer">Olivier Langlois</a>), I can determine whether a class has a type defined:</p>
  
  <pre><code>template&lt;typename T&gt; struct hasType
  {
      template&lt;typename C&gt; static char test( typename C::Type );
      template&lt;typename C&gt; static char* test(...);
      enum{ Value= sizeof(test&lt;T&gt;(0))==1 };
  };
  </code></pre>
  
  <p>I can also determine whether a class has a variable:</p>
  
  <pre><code>template&lt;typename T&gt; struct hasType
  {
      template&lt;typename C&gt; static char test( decltype(C::var) );
      template&lt;typename C&gt; static char* test(...);
      enum{ Value= sizeof(test&lt;T&gt;(0))==1 };
  };
  </code></pre>
  
  <p>However, neither <code>decltype(c::func)</code> nur <code>decltype(c::func())</code> (which depends on the parameters) works for member functions.
  Is there a way to do this or will I have to create a functor in every class and detect it with <code>typename C::functor</code>?</p>
  
  <p><b>Edit</b>: You're both right, but since I'll also have to test for a type I'll use <code>decltype(&amp;C::func)</code> (which should obviously be a pointer).</p>