title: Using SFINAE to select function based on whether a particular overload of a function exists
body: <p>I have been trying to choose between two templated functions based on whether an overload <code>operator&lt;&lt;(std::ostream&amp;, const T&amp;)</code> exists.</p>
  
  <p>Example:</p>
  
  <pre><code>template &lt;typename T, typename std::enable_if&lt;/* ? */, int&gt;::type = 0&gt;
  std::string stringify(const T&amp; t)
  {
      std::stringstream ss;
      ss &lt;&lt; t;
      return ss.str();
  }
  
  template &lt;typename T, typename std::enable_if&lt;/* ? */, int&gt;::type = 0&gt;
  std::string stringify(const T&amp; t)
  {
      return "No overload of operator&lt;&lt;";
  }
  
  struct Foo { };
  
  int main()
  {
      std::cout &lt;&lt; stringify(11) &lt;&lt; std::endl;
      std::cout &lt;&lt; stringify(Foo{}) &lt;&lt; std::endl;
  }
  </code></pre>
  
  <p>Is this possible? And if so, how would you solve this problem?</p>