Skip to content

add utility for ordering category #60

@DNKpp

Description

@DNKpp
template <class T>
concept odering_category = std::same_as<T, std::strong_ordering>
			|| std::same_as<T, std::weak_ordering>
			|| std::same_as<T, std::partial_ordering>;

template <class T, odering_category Alternative>
struct ordering_category_of_or
{
	using type = Alternative;
};

template <std::three_way_comparable T, odering_category Alternative>
struct ordering_category_of_or<T, Alternative>
{
	using type = std::compare_three_way_result_t<T>;
};

template <class T, class Alternative>
using ordering_category_of_or_t = typename ordering_category_of_or<T, Alternative>::type;

May be useful.

See https://en.cppreference.com/w/cpp/utility/compare/common_comparison_category

  template<class T, class Cat>
  concept __ComparesAs = std::same_as<std::common_comparison_category_t<T, Cat>, Cat>;

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions