BAN: Move RemoveReference and IsLValueReference to their own header

Also implement basic Less, Equal, Greater
This commit is contained in:
Bananymous 2023-01-18 13:38:35 +02:00
parent 59fa4055a6
commit ef2e8f1a2f
2 changed files with 28 additions and 13 deletions

View File

@ -1,21 +1,10 @@
#pragma once
#include <BAN/Traits.h>
namespace BAN
{
template<typename T>
struct RemoveReference { using type = T; };
template<typename T>
struct RemoveReference<T&> { using type = T; };
template<typename T>
struct RemoveReference<T&&> { using type = T; };
template<typename T>
struct IsLValueReference { static constexpr bool value = false; };
template<typename T>
struct IsLValueReference<T&> { static constexpr bool value = true; };
template<typename T>
constexpr typename RemoveReference<T>::type&& Move(T&& arg)
{

26
BAN/include/BAN/Traits.h Normal file
View File

@ -0,0 +1,26 @@
#pragma once
namespace BAN
{
template<typename T>
struct RemoveReference { using type = T; };
template<typename T>
struct RemoveReference<T&> { using type = T; };
template<typename T>
struct RemoveReference<T&&> { using type = T; };
template<typename T>
struct IsLValueReference { static constexpr bool value = false; };
template<typename T>
struct IsLValueReference<T&> { static constexpr bool value = true; };
template<typename T>
struct Less { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs < rhs; } };
template<typename T>
struct Equal { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs == rhs; } };
template<typename T>
struct Greater { constexpr bool operator()(const T& lhs, const T& rhs) const { return lhs > rhs; } };
}