Simplest way to bypass this issue, I think:
template <int N>
struct A {
B<::A> b;
};
Although it's actually a very interesting issue because it seems that B<A>
should work. From ยง14.6.1 [temp.local]/p1 of N3936:
Like normal (non-template) classes, class templates have an
injected-class-name (Clause 9). The injected-class-name can be used as
a template-name or a type-name. When it is used with a
template-argument-list, as a template-argument for a template
template-parameter, or as the final identifier in the
elaborated-type-specifier of a friend class template declaration, it
refers to the class template itself. Otherwise, it is equivalent to
the template-name followed by the template-parameters of the class
template enclosed in <>.
So it seems like B<A>
should be equivalent to B<::A>
. GCC 4.8 accepts the code in the OP, though Clang 3.4 doesn't.