I want to doublecheck that I have correct understanding on how forward overloads work
template< class T >
constexpr T&& forward( std::remove_reference_t<T>& t ) noexcept;
template< class T >
constexpr T&& forward( std::remove_reference_t<T>&& t ) noexcept;
If we call the forward with some local variable n
, say it's int
, overloads will be specified as
constexpr int&& forward( int& t ) noexcept;
constexpr int&& forward( int&& t ) noexcept;
So the first one will be chosen for our case. If we call forward with just 4
overloads will be specified same, but second version will be chosen. So first overload always catch all lvalues, and second all rvalues. Correct?
Aucun commentaire:
Enregistrer un commentaire