std::move casts an expression to an rvalue, enabling an overload or constructor that can move its contents instead of copying them. section 2.2.3 section 2.4
Use std::move with these rules in mind:
- A named rvalue-reference parameter is an lvalue inside its function, so std::move casts it back to an rvalue. section 2.2.3
- Moving can let vector operations select a move constructor and avoid unnecessary copies. section 2.2.3
- After moving, the original value remains valid but has an unspecified state and is generally no longer useful. section 2.2.3
- Prefer emplace_back when passing a temporary directly; std::move is useful when forwarding a named value. section 2.2.3
Forwarding a value inside push_back
A push_back overload taking T&& can call emplace_back(std::move(value)). Without the cast, the named value is treated as an lvalue and may select the copy constructor; with it, the rvalue overload can be selected. section 2.2.3
void push_back( T&& value ) {
emplace_back(std::move(value));
}
The compact implementation shows how std::move forwards a named parameter to an emplacement operation. section 2.2.3


