我已经定义了这个类
template <typename... Ts> struct Bar {
using inner_type = /* whatever */;
};
现在,我需要定义一个模板类Foo
,其模板参数是一些参数包,并且实例化为该参数包的类型为Bar::inner_type
的值。不幸的是,我似乎做不到。如果我这样定义它:
template <Bar<Ts...>::inner_type SomeValue, typename... Ts> struct Foo { };
编译器在使用 Ts
时无法识别它,因为它还没有看到参数包;但是如果我这样定义:
template <typename... Ts, Bar<Ts...>::inner_type SomeValue> struct Foo { };
编译器嘲笑了我在其他模板参数之前使用参数包的尝试。那么我该怎么做呢?注意:如果有影响的话,这在我的GCC 4.9.3上失败了。
template <int I>
)? - bolovtemplate <typename T, T t> struct Foo;
吗? - Jarod42