forked from Alepha/Alepha
62 lines
1.1 KiB
C++
62 lines
1.1 KiB
C++
static_assert( __cplusplus > 2023'00 );
|
|
|
|
#pragma once
|
|
|
|
#include <Alepha/Alepha.h>
|
|
|
|
#include <map>
|
|
#include <functional>
|
|
#include <type_traits>
|
|
|
|
#include <Alepha/Enum.h>
|
|
|
|
namespace Alepha::Hydrogen::Utility ::detail:: NamedComparator_m
|
|
{
|
|
inline namespace exports
|
|
{
|
|
using ComparatorName= Enum
|
|
<
|
|
"eq"_value,
|
|
"ne"_value,
|
|
"lt"_value,
|
|
"gt"_value,
|
|
"le"_value,
|
|
"ge"_value
|
|
>;
|
|
}
|
|
|
|
struct comparator
|
|
{
|
|
constexpr auto
|
|
operator () ( const ComparatorName &lhs, const ComparatorName &rhs ) const
|
|
{
|
|
return lhs.get_index() < rhs.get_index();
|
|
}
|
|
};
|
|
|
|
namespace exports
|
|
{
|
|
template< typename Type >
|
|
auto
|
|
getComparatorMap()
|
|
{
|
|
std::map< ComparatorName, std::function< bool ( Type, Type ) >, comparator > rv
|
|
{
|
|
{ "eq"_value, std::equal_to<>{} },
|
|
{ "ne"_value, std::not_equal_to<>{} },
|
|
{ "lt"_value, std::less<>{} },
|
|
{ "gt"_value, std::greater<>{} },
|
|
{ "le"_value, std::less_equal<>{} },
|
|
{ "ge"_value, std::greater_equal<>{} },
|
|
};
|
|
|
|
return rv;
|
|
};
|
|
}
|
|
}
|
|
|
|
namespace Alepha::Hydrogen::Utility::inline exports::inline NamedComparator_m
|
|
{
|
|
using namespace detail::NamedComparator_m::exports;
|
|
}
|