From 124afbecaad546b1a43712f6cf2ff691e00d2bee Mon Sep 17 00:00:00 2001 From: Bananymous Date: Tue, 17 Jan 2023 11:15:57 +0200 Subject: [PATCH] BAN: Add Forward() --- BAN/include/BAN/Move.h | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/BAN/include/BAN/Move.h b/BAN/include/BAN/Move.h index 056d26b32..1270874e5 100644 --- a/BAN/include/BAN/Move.h +++ b/BAN/include/BAN/Move.h @@ -3,17 +3,36 @@ namespace BAN { - template - struct RemoveReference { typedef T type; }; + template + struct RemoveReference { using type = T; }; + template + struct RemoveReference { using type = T; }; + template + struct RemoveReference { using type = T; }; - template - struct RemoveReference { typedef T type; }; + template + struct IsLValueReference { static constexpr bool value = false; }; + template + struct IsLValueReference { static constexpr bool value = true; }; - template - struct RemoveReference { typedef T type; }; - template - typename RemoveReference::type&& - Move( T&& Arg ) { return (typename RemoveReference::type&&)Arg; } + template + constexpr typename RemoveReference::type&& Move(T&& arg) + { + return static_cast::type&&>(arg); + } + + template + constexpr T&& Forward(typename RemoveReference::type& arg) + { + return static_cast(arg); + } + + template + constexpr T&& Forward(typename RemoveReference::type&& arg) + { + static_assert(!IsLValueReference::value); + return static_cast(arg); + } } \ No newline at end of file