【发布时间】:2021-02-16 21:08:46
【问题描述】:
给定:
template<typename T>
struct Foo
{
template<typename U>
struct Bar {};
/* many more members */
}
和
template<typename F>
struct Zoo {};
我需要只有 Bar 将专门用于当封闭类 Foo 的类型为 Foo<Zoo<F>> 时,无论 F 是什么。
我不想将 Foo 部分专门化为 Zoo<F>,因为我需要再次声明它的所有成员。
我不明白为什么以下内容无法编译:
template<typename F>
template<typename U>
struct Foo<Zoo<F>>::Bar {}
因为我希望 Foo<Zoo<F>> 被视为主要的 Foo 模板,其模板参数设置为 Zoo<F>,并且只有 Bar 应该是专门的。
【问题讨论】:
标签: templates nested template-specialization template-templates