title: Templated unions in c++11
body: <p>Does the c++11 standard say anything about templated unions?  (I can't find anything in <a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf">http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2011/n3242.pdf</a>, but I haven't read it that carefully.)</p>
  
  <p>I have</p>
  
  <pre><code>template&lt;typename T&gt;
  union u {
    T a;
    char b;
  };
  
  template&lt;typename T&gt;
  u&lt;T&gt; make_u(T t) {
    return { .a = t };
  }
  
  int main() {
    return make_u&lt;int&gt;(1).a;
  }
  </code></pre>
  
  <p>This code causes <code>icpc -std=c++11</code> to say <code>error: a designator into a template-dependent type is not allowed</code>, <code>g++ -std=c++0x</code> to say <code>error: expected primary-expression before ‘.’ token</code>, and <code>g++ -std=c++11</code> (version 4.8.0 (experimental)) to say <code>internal compiler error: in lookup_field_1, at cp/search.c:387</code>.  I can get around this by replacing <code>{ .a = t }</code> with <code>t</code>.  However, I could not do this for fields which are not the first member of the union.  Is there a way to pick some member other than the first one in a templated union, where the relevant member is template-dependent?  (I could, of course, declare a union on the stack, and set the member equal to the value I want.  But I could not do this in an initializer list or in a <code>constexpr</code> function.)</p>