ΒΆtemplate <class T>
inline constexpr T&& forward(
    std::remove_reference_t<T>& t) noexcept

Description

Move from non-reference values but pass through and preserve references. Typically, passing an rvalue reference will convert it to an lvalue. Using `sus::forward <T >(t)` on an rvalue reference `T & & t` will preserve the rvalue nature of the reference. Other reference types are also forwarded unchanged. The type argument must be provided, and should be the `T` from a `T & & ` typename in order to properly preserve the reference type of the object of type `T & & `. # Universal references and moves In the common case, when you want to receive a parameter that will be moved, it should be received by value. However, library implementors sometimes with to receive an *rvalue reference*. If you find yourself needing to [`move()`]($sus::mem::move) from a universal reference instead of [`forward()`]($sus::mem::forward), such as to construct a value type `T` from a universal reference `T & & ` without introducing a copy, use [`IsMoveRef`]($sus::mem::IsMoveRef) to constrain the universal reference to be an rvalue, and use [`move()`]($sus::mem::move) instead of [`forward()`]($sus::mem::forward).

Declared at: sus/mem/forward.h:46

Templates

T

Parameters

std::remove_reference_t<T>& t