title: Checking correctness of function call expression
body: <p><code>std::result_of</code> computes the return type of a calling expression at compile time.</p>
  
  <p>As <a href="http://en.cppreference.com/w/cpp/types/result_of">the reference</a> says, if the call is ill-formed the instantation of <code>std::result_of</code> results in a compilation error. But suppose that what we need is to check if the call is well formed, before getting the result type.</p>
  
  <p><strong>Is there any way to write a trait that checks if a calling expression is well-formed?</strong></p>
  
  <p>Something like:</p>
  
  <pre><code>template&lt;typename F , typename... ARGS&gt;
  struct is_valid_call : public impl::is_valid_call&lt;F,typelist&lt;ARGS...&gt;&gt;
  {};
  
  namespace impl
  {
      struct sfinae_result{};
  
      template&lt;typename F , typename ARGS , typename ENABLED = sfinae_result&gt;
      struct is_valid_call;
  
      template&lt;typename F , typename... ARGS&gt;
      struct is_valid_call&lt;F,typelist&lt;ARGS...&gt;,
                           decltype( std::declval&lt;F&gt;()(std::declval&lt;ARGS&gt;()...) )
                          &gt; : 
          public std::true_type
      {};
  
      template&lt;typename F , typename... ARGS&gt;
      struct is_valid_call&lt;F,typelist&lt;ARGS...&gt;,sfinae_result&gt; : 
          public std::false_type
      {};
  }
  </code></pre>
  
  <p><strong>EDIT:</strong> Of course the solution posted <a href="http://ideone.com/yuXO8R">doesn't work</a></p>