nkn*_*ght 5 c++ variadic-templates c++11
可能重复:
括号可以将任意标识符作为参数吗?C++
我的问题是关于使用参数包'unpack'运算符,....下面的代码片段在g ++ 4.7.1中给出了编译器错误(在'...'之前的预期参数包,在最后一行),我想知道为什么.
template<class T> struct type_wrapper
{ typedef T type; };
template<class...Ts> struct variadic_wrapper { };
// This compiles:
template<class...Ts> struct variadic_type_wrapper
{ typedef variadic_wrapper<typename type_wrapper<Ts>::type...> type; };
// Parentheses screw it up:
// Error: expected parameter pack before '...'
template<class...Ts> struct variadic_type_wrapper
{ typedef variadic_wrapper<(typename type_wrapper<Ts>::type)...> type; };
Run Code Online (Sandbox Code Playgroud)
表达式(...)隐藏了底层类型的arity吗?谢谢你清理这个!
| 归档时间: |
|
| 查看次数: |
154 次 |
| 最近记录: |