lig*_*ulb 1 c++ arrays copy-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]; });
}
};
Run Code Online (Sandbox Code Playgroud)
我不想使用std::array,并且复制ctor中有一些调试信息,因此我不能依赖默认值。