For a C style array, what will happen when I run float *fp1 = std::move(fp);
, as seen in the following code marked (1)
? Is it the same as float *fp1 = fp;
, as seen in the following code marked (2)
?
I printed the results and it seems they are the same. In general, std::move
will do nothing if the object is not movable, right?
int main()
{
float *fp = new float[20];
//float *fp1 = std::move(fp); //(1)
float *fp1 = fp; //(2)
std::cout << "fp: " << fp << " fp1: "<< fp1 << std::endl;
unique_ptr<float> u_fp(fp);
cout << "u_fp : " << u_fp.get() << endl;
unique_ptr<float> u_fp1 = std::move(u_fp);
}