The following is a snippet of code:
int i=0;
int&&k=std::move(i);
In c ++ primer move
template <typename T>
typename remove_reference<T>::type &&move(T&& t)
{return static_cast<typename remove_reference<T>::type&&>(t);}
As far as I know, this pattern std::movesubtracts a function like
int&& move(int& t){return static_cast<int&&>(t);}
As a comparison and to develop my question, consider an example:
int test(int k){k=66;return k;}
int k;
int a=test(k);
The above code will be compiled as:
int temp;
temp=k;
int a=temp;
Similarly, I think that the first code fragment will be compiled as:
int&& temp=0;
int&& k=temp;
Which seems wrong because it tempis an lvalue, did I get something wrong?
source
share