这是我尝试做的最简单的案例:
template <template <typename...> class Wrapper>
struct WrapperTraits { };
template <typename... Whatever>
struct Foo {
private:
// I want Foo here to refer to the template, and not the current
// concrete type (which is injected into the namespace by default)
using Traits = WrapperTraits<Foo>;
};
int main()
{
return 0;
}
这里有关于clang 3.6的错误(它在gcc 4.8和5.2上编译得很好):
error: template argument for template template parameter must be a class template or type alias template
using Traits = WrapperTraits<Foo>;
^
1 error generated.
Compilation failed
以下是关于godbolt的问题示例:https://goo.gl/cSx6QR
感谢您的帮助!
答案 0 :(得分:2)
没关系,明白了。需要将其范围限定在它所在的命名空间中:
template <template <typename...> class Wrapper>
struct WrapperTraits { };
template <typename... Whatever>
struct Foo {
private:
using Traits = WrapperTraits<::Foo>; // explicit namespace
};
int main()
{
return 0;
}