title: Using `std::conditional_t` to define a class' `typedef` in dependence of its template parameter
body: <p>I try to use <code>std::conditional_t</code> to define a class <code>A</code>'s <code>typedef</code> in dependence of its template parameter <code>T</code>:</p>
  
  <pre><code>template&lt; typename T &gt;
  class A
  {
    public:
      typedef std::conditional_t&lt; std::is_fundamental&lt;T&gt;::value, T, decltype(std::declval&lt;T&gt;().foo())&gt; type;
  };
  
  template&lt; typename T &gt;
  class B
  {
    public:
      T foo()
      {
        // ...
      }
  };
  
  
  int main()
  {
    typename A&lt; int &gt;::type a = 5;    // causes an error
    typename A&lt; B&lt;int&gt; &gt;::type b = 5; // does not cause an error
  
    return 0;
  }
  </code></pre>
  
  <p>Unfortunately, the code does not compile. Error:</p>
  
  <pre><code>error: member reference base type 'int' is not a structure or union
          typedef std::conditional_t&lt; std::is_fundamental&lt;T&gt;::value, T, decltype(std::declval&lt;T&gt;().foo())&gt; type;
  </code></pre>
  
  <p>Does anyone know how to fix it?</p>