title: Why does auto return type deduction work with not fully defined types?
body: <p>Consider the following:</p>
  
  <pre><code>template&lt;typename Der&gt;
  struct Base {
      // NOTE: if I replace the decltype(...) below with auto, code compiles
      decltype(&amp;Der::operator()) getCallOperator() const {
          return &amp;Der::operator();
      }
  };
  
  struct Foo : Base&lt;Foo&gt; {
      double operator()(int, int) const {
          return 0.0;
      }
  };
  
  int main() {
      Foo f;
      auto callOp = f.getCallOperator();
  }
  </code></pre>
  
  <p>I want to create a member function in CRTP base class with a return type depending on signature of the <code>operator()</code> in the derived class. However <code>decltype(&amp;Der::operator())</code> fails to compile; The <code>operator()</code> member function in <code>Foo</code> is not visible. I assume that this is because the base class template is instantiated before <code>Foo</code> is fully defined.</p>
  
  <p>Surprisingly, if I place <code>auto</code> for the return type it compiles. I assumed that <code>auto</code> would make the compiler deduce the return type from the function body and fail - because the body uses the not fully defined <code>Foo</code> type.</p>
  
  <p>This behavior is the same for both MSVC 2015.3 and Clang 3.8</p>
  
  <p>Why did the code start to work with <code>auto</code>? Does <code>auto</code> type deduction somehow "delay" the instantiation? Or use a different context than a hand-written return type expression?</p>