Looking at the documentation for std::forward
,
template< class T >
constexpr T&& forward( typename std::remove_reference<T>::type& t ) noexcept;
template< class T >
constexpr T&& forward( typename std::remove_reference<T>::type&& t ) noexcept;
Both functions return T&&
, which (correct me if I'm wrong) collapses to
T&
ifT
is an lvalue referenceT&&
ifT
is an rvalue reference, or ifT
is not a reference
For an arbitrary type T
which may be a reference, does reference collapsing always cause forward<T>
to do the same as forward<T&&>
?
If so, is there any reason to use forward<T&&>
?