title: Use decltype on inherited template static member function using GCC
body: <p>I have the below working code available on <a href="http://coliru.stacked-crooked.com/a/dcf208438edb917d" rel="nofollow noreferrer">coliru.stacked-crooked.com</a>.</p>
  
  <p>As <code>static std::false_type check(...)</code> is duplicated, I wonder if we could factorize it. For instance within a base class. As pointed out by <a href="https://stackoverflow.com/a/29013355/938111">Jonathan Wakely</a> my attempt at the bottom of my question compiles using Clang, but not using GCC.</p>
  
  <p>I have tried many possibilities but it seems impossible to use <code>decltype</code> on inherited template static function using GCC. </p>
  
  <p>Questions: <br>
  1. <strong>Is GCC-4.9 compliant with C++11 standard on this point?</strong><br>
  2. <strong>What is the GCC-compliant workaround to use <code>decltype</code> on inherited template static member function?</strong></p>
  
  <pre><code>#include &lt;type_traits&gt;
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  
  template&lt;typename T&gt;
  struct is_addable
  {
    template&lt;typename U&gt; static std::false_type check(...);
    template&lt;typename U&gt; static auto            check(int) 
         -&gt; decltype( std::declval&lt;U&gt;() + std::declval&lt;U&gt;(), std::true_type{});
    using type = decltype(check&lt;T&gt;(0));
  };
  
  template&lt;typename T&gt;
  struct is_multiplicable
  {
    template&lt;typename U&gt; static std::false_type check(...);
    template&lt;typename U&gt; static auto            check(int)
      -&gt; decltype( std::declval&lt;U&gt;() * std::declval&lt;U&gt;(), std::true_type{});
    using type = decltype(check&lt;T&gt;(0));
  };
  
  int main()
  {
    std::cout &lt;&lt;"is_addable\n";
    std::cout &lt;&lt;" long:   "&lt;&lt; is_addable&lt;long&gt;::type::value        &lt;&lt;'\n';
    std::cout &lt;&lt;" string: "&lt;&lt; is_addable&lt;std::string&gt;::type::value &lt;&lt;'\n';
    std::cout &lt;&lt;" void:   "&lt;&lt; is_addable&lt;void&gt;::type::value        &lt;&lt;'\n';
  
    std::cout &lt;&lt;"is_multiplicable\n";
    std::cout &lt;&lt;" long:   "&lt;&lt; is_multiplicable&lt;long&gt;::type::value        &lt;&lt;'\n';
    std::cout &lt;&lt;" string: "&lt;&lt; is_multiplicable&lt;std::string&gt;::type::value &lt;&lt;'\n';
    std::cout &lt;&lt;" void:   "&lt;&lt; is_multiplicable&lt;void&gt;::type::value        &lt;&lt;'\n';
  }
  </code></pre>
  
  <h3>One of my attempts</h3>
  
  <p><strong>Edit:</strong> added <code>template&lt;typename U&gt;</code> as pointed out by <a href="https://stackoverflow.com/a/29013355/938111">Jonathan Wakely</a></p>
  
  <pre><code>struct default_check
  { 
    template&lt;typename U&gt;
    static std::false_type check(...);
  };
  
  template&lt;typename T&gt;
  struct is_addable : default_check
  {
    using default_check::check;
  
    template&lt;typename U&gt; static auto check(int) 
         -&gt; decltype( std::declval&lt;U&gt;() + std::declval&lt;U&gt;(), std::true_type{});
  
    using type = decltype(check&lt;T&gt;(0));
  };
  </code></pre>
  
  <h3>GCC-4.9.2 fails on <a href="http://coliru.stacked-crooked.com/a/82a140b210aa6771" rel="nofollow noreferrer">coliru.stacked-crooked.com</a></h3>
  
  <pre><code>&gt; g++ -std=c++11 -Wall -pedantic -Wextra -Wfatal-errors main.cpp
  main.cpp: In instantiation of 'struct is_addable&lt;void&gt;':
  main.cpp:38:63:   required from here
  main.cpp:19:30: error: no matching function for call to 'is_addable&lt;void&gt;::check(int)'
     using type = decltype(check&lt;T&gt;(0));
                                ^
  compilation terminated due to -Wfatal-errors.
  </code></pre>
  
  <h3>Clang-3.4.1 succeeds on <a href="http://goo.gl/CTS1Pc" rel="nofollow noreferrer">godbolt.org</a></h3>
  
  <pre><code>&gt; clang++ -std=c++11 -Wall -pedantic -Wextra -Wfatal-errors
  </code></pre>