BAN: Add Forward()
This commit is contained in:
parent
b9a4530e54
commit
124afbecaa
|
@ -3,17 +3,36 @@
|
||||||
namespace BAN
|
namespace BAN
|
||||||
{
|
{
|
||||||
|
|
||||||
template <class T>
|
template<typename T>
|
||||||
struct RemoveReference { typedef T type; };
|
struct RemoveReference { using type = T; };
|
||||||
|
template<typename T>
|
||||||
|
struct RemoveReference<T&> { using type = T; };
|
||||||
|
template<typename T>
|
||||||
|
struct RemoveReference<T&&> { using type = T; };
|
||||||
|
|
||||||
template <class T>
|
template<typename T>
|
||||||
struct RemoveReference<T&> { typedef T type; };
|
struct IsLValueReference { static constexpr bool value = false; };
|
||||||
|
template<typename T>
|
||||||
|
struct IsLValueReference<T&> { static constexpr bool value = true; };
|
||||||
|
|
||||||
template <class T>
|
|
||||||
struct RemoveReference<T&&> { typedef T type; };
|
|
||||||
|
|
||||||
template<class T>
|
template<typename T>
|
||||||
typename RemoveReference<T>::type&&
|
constexpr typename RemoveReference<T>::type&& Move(T&& arg)
|
||||||
Move( T&& Arg ) { return (typename RemoveReference<T>::type&&)Arg; }
|
{
|
||||||
|
return static_cast<typename RemoveReference<T>::type&&>(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr T&& Forward(typename RemoveReference<T>::type& arg)
|
||||||
|
{
|
||||||
|
return static_cast<T&&>(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename T>
|
||||||
|
constexpr T&& Forward(typename RemoveReference<T>::type&& arg)
|
||||||
|
{
|
||||||
|
static_assert(!IsLValueReference<T>::value);
|
||||||
|
return static_cast<T&&>(arg);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue