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 of is_three_way_comparable. Used to determine the type of the returned result of three-way comparing a TLhs with a TRhs, 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 type TLhs is equality comparable with a value of type TRhs.

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 type TLhs is inequality comparable with a value of type TRhs.

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 type TLhs is less-than comparable with a value of type TRhs.

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 type TLhs is less-than-or-equal comparable with a value of type TRhs.

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 type TLhs is greater-than comparable with a value of type TRhs.

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 type TLhs is greater-than-or-equal comparable with a value of type TRhs.

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 type TLhs is three-way comparable to a value of type TRhs.

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 type TRhs.

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 type TRhs.

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 type TRhs.

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 type TRhs.

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 type TRhs.

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 type TRhs.

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 type TRhs.

In addition to providing the static member value, indicating whether a TLhs is three-way comparable with a TRhs, also provides the member typedef type result_type equal to the type of the returned result of three-way comparing a TLhs with a TRhs, 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 checking value in any way (e.g. in a SFINAE-compatible context or C++20 requires clause): if is_three_way_comparable<TLhs, TRHs>::value == false, then result_type will be void