title: Clang candidate template ignored: substitution failure (also fails to compile with gcc, VC works fine)
body: <p>I am having an issue with Clang 3.5.  The following is a self-contained repro.  This code compiles with VC12.  With Clang I get the following error:</p>
  
  <pre><code>1&gt;C:\Users\jcuyle\code\branches\dev\ClientSDK\test\CompilerTestbed\CompilerTestbed.cpp(111,5): error : no matching function for call to 'out_from_storage'
  1&gt;          }( util::out_from_storage( rv ) );
  1&gt;             ^~~~~~~~~~~~~~~~~~~~~~
  1&gt;  C:\Users\jcuyle\code\branches\dev\ClientSDK\test\CompilerTestbed\CompilerTestbed.cpp(37,13):  note: candidate template ignored: substitution failure [with storage_t = std::chrono::time_point&lt;std::chrono::_V2::system_clock, std::chrono::duration&lt;long, std::ratio&lt;1, 1000000000&gt; &gt; &gt; &amp;]: no matching function for call to 'out_from_storage'
  1&gt;  inline auto out_from_storage( storage_t &amp;&amp; storage ) -&gt; decltype( util::details::template out_from_storage( std::forward&lt; storage_t &gt;( storage ) ) )
  1&gt;              ^                                                     ~~~~
  1&gt;  1 error generated.
  </code></pre>
  
  <p>Here's the code:</p>
  
  <pre><code>#include &lt;stdint.h&gt;
  
  #include &lt;type_traits&gt;
  #include &lt;chrono&gt;
  #include &lt;utility&gt;
  
  namespace util
  {
  namespace details
  {
  
  template&lt; typename RTy, typename Ty, typename enable = void &gt;
  inline RTy out_from_storage( Ty );
  
  template&lt; typename Ty, typename = typename std::enable_if&lt; std::is_trivial&lt; typename std::decay&lt; Ty &gt;::type &gt;::value, Ty &gt;::type &gt;
  inline typename std::add_pointer&lt; typename std::decay&lt; Ty &gt;::type &gt;::type out_from_storage( Ty&amp;&amp; t )
  {
      return &amp;t;
  }
  
  } // namespace details
  
  template&lt; typename storage_t &gt;
  inline auto out_from_storage( storage_t &amp;&amp; storage ) -&gt; decltype( util::details::out_from_storage( std::forward&lt; storage_t &gt;( storage ) ) )
  {
      return util::details::out_from_storage( std::forward&lt; storage_t &gt;( storage ) );
  }
  
  } // namespace util
  
  namespace util
  {
  namespace details
  {
  
  template&lt; typename enable = void &gt;
  inline int64_t out_from_storage( std::chrono::system_clock::time_point &amp; storage )
  {
      return std::chrono::system_clock::to_time_t( storage );
  }
  
  } // namespace details
  } // namespace util
  
  int main(int argc, char * argv[])
  {
      std::chrono::system_clock::time_point out = std::chrono::system_clock::now( );
      util::out_from_storage( out ); // error
      util::details::out_from_storage( out ); // no error
  
      return 0;
  }
  </code></pre>
  
  <p>While this example is fairly trivial, the code is a chunk of a utility library for marshaling types across a DLL boundary.  There are a number of similar utility functions and a large number of specializations for different types.  All works fine under VC, and I suspect there's just some bogus syntax that VC accepts but needs to be slightly more correct for Clang and gcc to accept.  Significant reordering of the code is difficult, and major rewrites of the system to use a completely different approach to specializing the conversion functions (e.g. yanking out the type_traits/enable_if and using tag dispatch or similar) are impractical.  If someone can explain why it is that Clang can't find the matching function call for util::details::out_from_storage( std::chrono::system_clock::time_point &amp; storage ) even though it pretty clearly exists (and VC can find it) I'd really appreciate it.  I'm very new to Clang and gcc.  Thanks!</p>