diff --git a/AK/StdLibExtras.h b/AK/StdLibExtras.h index c68f3c93e2..e0fba83309 100644 --- a/AK/StdLibExtras.h +++ b/AK/StdLibExtras.h @@ -81,17 +81,6 @@ inline T&& move(T& arg) # pragma clang diagnostic pop #endif -template -struct Identity { - typedef T Type; -}; - -template -inline constexpr T&& forward(typename Identity::Type& param) -{ - return static_cast(param); -} - template inline T exchange(T& a, U&& b) { @@ -150,6 +139,14 @@ struct IntegralConstant { typedef IntegralConstant FalseType; typedef IntegralConstant TrueType; +template +struct IsLvalueReference : FalseType { +}; + +template +struct IsLvalueReference : TrueType { +}; + template struct __IsPointerHelper : FalseType { }; @@ -293,11 +290,37 @@ struct Conditional { typedef FalseType Type; }; +template +struct RemoveReference { + typedef T Type; +}; +template +struct RemoveReference { + typedef T Type; +}; +template +struct RemoveReference { + typedef T Type; +}; + +template +inline constexpr T&& forward(typename RemoveReference::Type& param) +{ + return static_cast(param); +} + +template +inline constexpr T&& forward(typename RemoveReference::Type&& param) noexcept +{ + static_assert(!IsLvalueReference::value, "Can't forward an rvalue as an lvalue."); + return static_cast(param); +} + } -using AK::Conditional; using AK::ceil_div; using AK::clamp; +using AK::Conditional; using AK::exchange; using AK::forward; using AK::IsSame;