title: Templated check for the existence of a class member function?
body: <p>Is it possible to write a template that changes behavior depending on if a certain member function is defined on a class?</p>
  
  <p>Here's a simple example of what I would want to write:</p>
  
  <pre><code>template&lt;class T&gt;
  std::string optionalToString(T* obj)
  {
      if (FUNCTION_EXISTS(T-&gt;toString))
          return obj-&gt;toString();
      else
          return "toString not defined";
  }
  </code></pre>
  
  <p>So, if <code>class T</code> has <code>toString()</code> defined, then it uses it; otherwise, it doesn't. The magical part that I don't know how to do is the "FUNCTION_EXISTS" part.</p>