Is a nested alias template that redeclares the same name valid?

只谈情不闲聊 提交于 2021-01-07 03:10:19

问题


Given some class template:

template <typename> struct T {};

a type alias declaration that changes the meaning of the name T like this is not allowed:

struct S {
    using T = T<void>;  // ill formed no diagnostic required
};

There is an explanation given here as to why this is the case, and it also suggests a fix:

struct S {
    using T = ::T<void>;  // ok
};

So my question is, how about an alias template as in this case?

struct S {
    template <typename> using T = T<void>;  // ok ?
};

Is this well formed? A type alias is a different kind of entity than an alias template, so I don't know if the reasoning from the linked answer applies.

For what it's worth, the diagnostic that gcc (helpfully) issues in the type alias example is not issued with the alias template example.

Here's the code to play with.

来源:https://stackoverflow.com/questions/63369264/is-a-nested-alias-template-that-redeclares-the-same-name-valid

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!