【发布时间】:2020-10-19 04:29:28
【问题描述】:
我有 3 个问题:
-
std::move可以移动内置类型吗?
int a = 10;
int b = std::move(a);
a 会是无效值吗?
- 可以
std::move移动指针
int *a = new int[10];
int *b = std::move(a);
a 会变成无效指针还是nullptr?
-
std::move可以移动一个 c 数组吗?
struct S {
int array[10];
}
S a;
for(int i=0; i<10; i++)
a.array[i]=1;
S b;
b = std::move(a);
a.array 会变成无效数组吗?
【问题讨论】: