【发布时间】:2013-10-27 17:05:12
【问题描述】:
如何创建具有std::tuple 类型成员的对象?
我试图编译这段代码。
6 template <class ... T>
7 class Iterator
8 {
9 public:
10 Iterator(T ... args)
11 : tuple_(std::make_tuple(args))
12 {
13 }
14
15 private:
16 std::tuple<T ...> tuple_;
17 };
但无法编译,出现以下错误。
variadic.cpp: In constructor ‘Iterator<T>::Iterator(T ...)’:
variadic.cpp:11:33: error: parameter packs not expanded with ‘...’:
variadic.cpp:11:33: note: ‘args’
代码有什么问题?
【问题讨论】: