Why does a class / function have two overloads, one for lvalue and one for rvalue?
For example, this video says that we have two overloads for vector<T>::push_back
void push_back( const T& value ); void push_back( T&& value );
Why can't we have only one overload by value,
void push_back( T value );
If this value is lvalue, the value will be copied, and if this value is rvalue, the value will be moved. Isn't that how it works and is guaranteed by the standard?
c ++ c ++ 11 move-semantics
balki
source share