Let's consider a set of template aliases:
template<class T> using foo = T*;
template<class T> using bar = T*;
template<class T> using buz = foo<T>;
template< template<class>class TT > struct id {};
using id_foo = id<foo>;
using id_bar = id<bar>;
using id_buz = id<buz>;
Are id_foo, id_bar, id_buz same or different types? Are foo, bar, buz same or different templates?
Various compilers have different opinions on that. Particularly,
buz is same as foo
Standard C++11 in the chapter 14.5.7 "Alias templates" is unclear.
As T.C. pointed out in his comment to the question, this is a known hole of the standard.
The current wording of 14.5.7 [temp.alias] deals only with the equivalence of a specialization of an alias template with the type-id after substitution. Wording needs to be added specifying under what circumstances an alias template itself is equivalent to a class template.
That is: any specialization of foo, bar and buz will represent the same type. But there is no guarantee that, when used as a template parameter, foo, bar and buz are interchangeable.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With