title: Accessing private nested class
body: <p>I made this simple class, which still is playing with my mind:</p>
  
  <pre><code>class A {
  private:
      class B {};
  
  public:
      B getB() {
          return B();
      };
  };
  </code></pre>
  
  <p>As of C++03, this class compiles fine, but there is just no <em>nice looking way</em> to assign the result of <code>getB()</code> to an lvalue, in the sense that:</p>
  
  <pre><code>A::B b = A().getB();
  </code></pre>
  
  <p>Does not compile.</p>
  
  <p>I got it by using an intermediate template, in this fashion:</p>
  
  <pre><code>template &lt;typename T&gt;
  struct HideType {
      typedef T type;
  };
  
  HideType&lt;A::B&gt;::type b = A().getB();
  </code></pre>
  
  <p>But this looks just terrible, for this simple task of getting an A::B lvalue variable.</p>
  
  <p>This is not true anymore as of C++11, or at least it is not with gcc. This code is still not valid:</p>
  
  <pre><code>A::B b = A().getB();
  </code></pre>
  
  <p>But this <strong>is</strong> valid:</p>
  
  <pre><code>auto b = A().getB();
  </code></pre>
  
  <p>Is there a loophole in the standard respect to this?</p>