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_typemember typedef ofis_three_way_comparable. Used to determine the type of the returned result of three-way comparing aTLhswith 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 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 typeTLhsis 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 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 typeTLhsis 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 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 typeTLhsis 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 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 typeTLhsis 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 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 typeTLhsis 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 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 typeTLhsis 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 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 typeTLhsis 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
TLhsis 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
TLhsis 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
TLhsis 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
TLhsis 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
TLhsis 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
TLhsis 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
TLhsis three-way comparable to a value of typeTRhs.In addition to providing the static member
value, indicating whether aTLhsis three-way comparable with aTRhs, also provides the membertypedeftyperesult_typeequal to the type of the returned result of three-way comparing aTLhswith 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_typeshould not be used as a short-hand or alternaitve to checkingvaluein any way (e.g. in a SFINAE-compatible context or C++20requiresclause): ifis_three_way_comparable<TLhs, TRHs>::value == false, thenresult_typewill bevoid
-
template<typename TLhs, typename TRhs>