, (values), . , (entities) . - /, . - - ( , , , , , ), . - (, , , ) ( , ), , , - .
11. . . rvalue-. std::move.
2011. ++ - (Move constructors, Move assignment operators).
, , , , Stack.
++11 -, (move constructors). . , - , rvalue- , . rvalue-, .. , , lvalue:
int x;
int & simpleRefToRValue = x + 2; // - rvalue
int && rvalueRefToRValue = x + 2; // , rvalue- rvalue
, ( , ). -. , - , - -. , , rvalue-.
, , - . , :
|
|
● ;
● .
std::move:
Int main ()
{
Stack s1;
Stack s2(20);
s1 = std::move(s2);
}
std::move ,
//
BigClass (BigClass && _temporar)
: s(std::move(_copy.s)) // !
{
}
};
std::move, .
, , . ,