是否可以使用基础类型的非默认构造函数通过相同的参数初始化std::tuple的所有元素?
template <typename... TElements>
struct Container {
// I'd wish to be able to do something like this:
Container(Foo foo, Bar bar)
: tuple(foo, bar)
{}
std::tuple<TElements...> tuple;
};
关键是我不知道元组的大小(它是由一个可变参数模板化的),所
我的印象是数组是不可复制的(或可赋值的)。
int x[5] = {1,2,3,4,5};
int y[5] = {6,7,8,9,0};
x = y; // Fails to compile
但是,当我将一个数组放入一个类中时,复制构造函数和赋值操作符就可以工作了(我可能会这么说,但这并不是我所期望的)。
#include <iostream>
struct X
{
virtual ~X(){} // Just in case it was something to do with POD
// make sure its no