title: Forward declaration of a class nested in in a class template, is it legal?
body: <p>Is this code legal under <code>C++14/17</code>?</p>
  
  <pre><code>template &lt;class T1, class T2 &gt;
  class Foo
  {
  public:
      class sentry;
  };
  
  template &lt;class T1,class T2 = int&gt;
  class Foo&lt;T1,T2&gt;::sentry
  {
  public:
      ~sentry() { }
  };
  </code></pre>
  
  <p>It compiles with <em>GCC 4.9.3</em> but fails with <em>GCC 5.3</em>. 
  <strong><a href="https://godbolt.org/z/S-pH6R" rel="nofollow noreferrer">Online demo</a></strong></p>
  
  <p>How can I fix this for <em>GCC 5.3</em>?</p>