title: Anonymous struct in typedef of trait class
body: <p>Sorry for the funny title.</p>
  
  <p>Prior to C++0x, there are <a href="https://stackoverflow.com/q/4659157/1968">restrictions</a> in the use of function-local structs (“local types”) as template arguments. My question is essentially if similar restrictions apply to anonymous structs. Specifically, in the context of a trait class:</p>
  
  <pre><code>template &lt;typename T&gt;
  struct trait;
  
  template &lt;&gt;
  struct trait&lt;int&gt; {
      typedef int type;
  };
  
  template &lt;typename T&gt;
  struct trait&lt;std::basic_string&lt;T&gt; &gt; {
      typedef struct {
          T value;
      } type;
  };
  
  trait&lt;std::string&gt;::type foo; // Is this valid?
  
  template &lt;typename T&gt;
  void f() { }
  
  f&lt;trait&lt;std::string&gt;::type&gt; &gt;(); // Is this?
  
  template &lt;typename T&gt;
  void g() { f&lt;typename trait&lt;T&gt;::type&gt;(); }
  
  g&lt;std::string&gt;(); // And this?
  </code></pre>
  
  <p>Is this valid and reliable? It compiles in recent versions of GCC and LLVM but I’m still insecure whether this is strictly valid, and whether it’s understood by VC++ and ICC.</p>