std::move explained with simple example
std::move is a C++11(Introduction to C++11) utility function which is used to convert an lvalue to rvalue expression to forcefully call the move constructor or move assignment operator which will improve the program’s performance drastically. This utility function is only change lvalue into rvalue expression that’s it. This function doesn’t do any kind of memory movement.
Implementation of this function is as follows:
From C++11 onwards:
template< class T >
typename std::remove_reference<T>::type&& move( T&& t );
From C++14 onwards:
template< class T >
constexpr typename std::remove_reference<T>::type&& move( T&& t );
Let’s take an example of usage of this move function:
(more…)