在构造函数中复制静态数组
Copy static array in constructor
是否有编译时表达式来在对象构造函数中复制数组?默认构造函数使用什么?我想要这样的东西:
struct A
{
int arr[100];
// I want something like this:
A(const A& arg) : arr{arg.arr...} {}
// what I use at the moment (a compile time loop):
A(const A& arg)
{
static_for<0, N>([&](auto i) { arr[i] = arg.arr[i]; });
}
};
我不想使用 std::array
,并且我在复制构造器中有一些调试信息,所以我不能依赖默认的。
是否有编译时表达式来在对象构造函数中复制数组?默认构造函数使用什么?我想要这样的东西:
struct A
{
int arr[100];
// I want something like this:
A(const A& arg) : arr{arg.arr...} {}
// what I use at the moment (a compile time loop):
A(const A& arg)
{
static_for<0, N>([&](auto i) { arr[i] = arg.arr[i]; });
}
};
我不想使用 std::array
,并且我在复制构造器中有一些调试信息,所以我不能依赖默认的。