Comparison Operator Detection#
- group comparison_operator_detection
Assortment of type traits to determine if two types are comparable.
Example:#
#include <hyperion/mpl/type_traits/is_comparable.h> using namespace hyperion::mpl::type_traits; struct not_comparable {}; static_assert(is_equality_comparable_v<int, int>); static_assert(!is_equality_comparable_v<not_comparable, not_comparable>);
Typedefs
-
template<typename TLhs, typename TRhs>
using three_way_compare_result_t = typename is_three_way_comparable<TLhs, TRhs>::result_type# Alias to the
result_type
member typedef ofis_three_way_comparable
. Used to determine the type of the returned result of three-way comparing aTLhs
with aTRhs
, i.e.decltype(std::declval<TLhs>() <=> std::declval<TRhs>())
- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
Variables
-
template<typename TLhs, typename TRhs>
static constexpr auto is_equality_comparable_v = is_equality_comparable<TLhs, TRhs>::value# Value of the type trait
is_equality_comparable
. Used to determine whether a value of typeTLhs
is equality comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
static constexpr auto is_inequality_comparable_v = is_inequality_comparable<TLhs, TRhs>::value# Value of the type trait
is_inequality_comparable
. Used to determine whether a value of typeTLhs
is inequality comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
static constexpr auto is_less_than_comparable_v = is_less_than_comparable<TLhs, TRhs>::value# Value of the type trait
is_less_than_comparable
. Used to determine whether a value of typeTLhs
is less-than comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
static constexpr auto is_less_than_or_equal_comparable_v = is_less_than_or_equal_comparable<TLhs, TRhs>::value# Value of the type trait
is_less_than_or_equal_comparable
. Used to determine whether a value of typeTLhs
is less-than-or-equal comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
static constexpr auto is_greater_than_comparable_v = is_greater_than_comparable<TLhs, TRhs>::value# Value of the type trait
is_greater_than_comparable
. Used to determine whether a value of typeTLhs
is greater-than comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
static constexpr auto is_greater_than_or_equal_comparable_v = is_greater_than_or_equal_comparable<TLhs, TRhs>::value# Value of the type trait
is_greater_than_or_equal_comparable
. Used to determine whether a value of typeTLhs
is greater-than-or-equal comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
static constexpr auto is_three_way_comparable_v = is_three_way_comparable<TLhs, TRhs>::value# Value of the type trait
is_three_way_comparable
. Used to determine whether a value of typeTLhs
is three-way comparable to a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
struct is_equality_comparable : public std::bool_constant<concepts::EqualityComparable<TLhs, TRhs>># - #include <hyperion/mpl/type_traits/is_comparable.h>
Type trait to determine whether a value of type
TLhs
is equality comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
struct is_inequality_comparable : public std::bool_constant<concepts::InequalityComparable<TLhs, TRhs>># - #include <hyperion/mpl/type_traits/is_comparable.h>
Type trait to determine whether a value of type
TLhs
is inequality comparable with a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
struct is_less_than_comparable : public std::bool_constant<concepts::LessThanComparable<TLhs, TRhs>># - #include <hyperion/mpl/type_traits/is_comparable.h>
Type trait to determine whether a value of type
TLhs
is less-than comparable to a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
struct is_less_than_or_equal_comparable : public std::bool_constant<concepts::LessThanOrEqualComparable<TLhs, TRhs>># - #include <hyperion/mpl/type_traits/is_comparable.h>
Type trait to determine whether a value of type
TLhs
is less-than-or-equal comparable to a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
struct is_greater_than_comparable : public std::bool_constant<concepts::GreaterThanComparable<TLhs, TRhs>># - #include <hyperion/mpl/type_traits/is_comparable.h>
Type trait to determine whether a value of type
TLhs
is greater-than comparable to a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
struct is_greater_than_or_equal_comparable : public std::bool_constant<concepts::GreaterThanOrEqualComparable<TLhs, TRhs>># - #include <hyperion/mpl/type_traits/is_comparable.h>
Type trait to determine whether a value of type
TLhs
is greater-than-or-equal comparable to a value of typeTRhs
.- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
-
template<typename TLhs, typename TRhs>
struct is_three_way_comparable : public std::false_type# - #include <hyperion/mpl/type_traits/is_comparable.h>
Type trait to determine whether a value of type
TLhs
is three-way comparable to a value of typeTRhs
.In addition to providing the static member
value
, indicating whether aTLhs
is three-way comparable with aTRhs
, also provides the membertypedef
typeresult_type
equal to the type of the returned result of three-way comparing aTLhs
with aTRhs
, i.e.decltype(std::declval<TLhs>() <=> std::declval<TRhs>())
- Template Parameters:
TLhs – The left-hand side argument of the comparison
TRhs – The right-hand side argument of the comparison
Note
Presence of
result_type
should not be used as a short-hand or alternaitve to checkingvalue
in any way (e.g. in a SFINAE-compatible context or C++20requires
clause): ifis_three_way_comparable<TLhs, TRHs>::value == false
, thenresult_type
will bevoid
-
template<typename TLhs, typename TRhs>