title: SFINAE issue with traits detecting division
body: <p>I have the following traits to detect if two type are divisible, and return the resulting operation type or another <code>Default</code> type otherwise:</p>
  
  <pre><code>struct default_t { };
  
  // Overloaded template for fallbacks
  template &lt;class U, class V&gt;
  default_t operator/(U, V);
  
  // If the expression std::declval&lt;U&gt;()/std::declval&lt;V&gt;() is valid,
  // gives the return type, otherwize provide Default.
  template &lt;class U, class V, class Default&gt;
  struct div_type_or {
      using type_ = decltype(std::declval&lt;U&gt;() / std::declval&lt;V&gt;());
      using type = typename std::conditional&lt;
          std::is_same&lt;type_, default_t&gt;{},
              Default,
              type_&gt;::type;
  };
  
  template &lt;class... Args&gt;
  using div_type_or_t = typename div_type_or&lt;Args...&gt;::type;
  </code></pre>
  
  <p>This works well with libstdc++, but not with libc++, when I try with a non-divisible <code>std::chrono::duration</code> type, e.g.:</p>
  
  <pre><code>struct A { };
  
  div_type_or_t&lt;std::chrono::seconds, A, int&gt; b;
  </code></pre>
  
  <p>I get the following error:</p>
  
  <blockquote>
    <p>/Library/Developer/CommandLineTools/usr/include/c++/v1/chrono:764:81:
    error: no type named 'type' in
          'std::__1::common_type'
                              typename common_type::type>::value>
                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~</p>
    
    <p>/Library/Developer/CommandLineTools/usr/include/c++/v1/chrono:777:7:
    note: in instantiation of default argument for
          '__duration_divide_imp >, A>' required here
        : __duration_divide_imp, _Rep2>
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ></p>
    
    <p>/Library/Developer/CommandLineTools/usr/include/c++/v1/chrono:784:10:
    note: in instantiation of template class
          'std::__1::chrono::__duration_divide_result >, A, false>'
          requested here typename __duration_divide_result, _Rep2>::type
             ^ </p>
    
    <p>test.cpp:16:46: note: while substituting deduced template arguments into function template 'operator/' [with _Rep1 = long
          long, _Period = std::__1::ratio&lt;1, 1>, <em>Rep2 = A]
        using type</em> = decltype(std::declval() / std::declval());
                                                 ^ </p>
    
    <p>test.cpp:24:1: note: in instantiation of template class
    'div_type_or >, A, D>' requested here using div_type_or_t = typename div_type_or::type; ^ </p>
    
    <p>test.cpp:48:19:
    note: in instantiation of template type alias 'div_type_or_t'
    requested here
                      div_type_or_t, D>{}, "");</p>
  </blockquote>
  
  <p>As I understand this, it is because the following overload of <code>operator/</code> for <code>std::chrono::duration</code> fails:</p>
  
  <pre><code>template&lt; class Rep1, class Period, class Rep2 &gt;
  duration&lt;typename std::common_type&lt;Rep1,Rep2&gt;::type, Period&gt;
      constexpr operator/( const duration&lt;Rep1, Period&gt;&amp; d,
                           const Rep2&amp; s );
  </code></pre>
  
  <p>I thought that since the <code>std::common_type</code> is part of the function signature, this would allow SFINAE to work and use my custom overload of <code>operator/</code> and thus deduce <code>default_t</code>, but apparently this does not work...</p>
  
  <p>Since this works with libstdc++, I just wanted to know if there was an issue with my code (maybe I did not understand the way SFINAE would work in this case) or if this was a libc++ bug?</p>