3.0 KiB
[compare.syn]
17 Language support library [support]
17.12 Comparisons [cmp]
17.12.1 Header synopsis [compare.syn]
The header specifies types, objects, and functions for use primarily in connection with the three-way comparison operator.
// all freestandingnamespace std {// [cmp.categories], comparison category typesclass partial_ordering; class weak_ordering; class strong_ordering; // named comparison functionsconstexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; }constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; }constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; }constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; }constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }// [cmp.common], common comparison category typetemplate<class... Ts>struct common_comparison_category {using type = see below; }; template<class... Ts>using common_comparison_category_t = typename common_comparison_category<Ts...>::type; // [cmp.concept], concept three_way_comparabletemplate<class T, class Cat = partial_ordering>concept three_way_comparable = see below; template<class T, class U, class Cat = partial_ordering>concept three_way_comparable_with = see below; // [cmp.result], result of three-way comparisontemplate<class T, class U = T> struct compare_three_way_result; template<class T, class U = T>using compare_three_way_result_t = typename compare_three_way_result<T, U>::type; // [comparisons.three.way], class compare_three_waystruct compare_three_way; // [cmp.alg], comparison algorithmsinline namespace unspecified {inline constexpr unspecified strong_order = unspecified; inline constexpr unspecified weak_order = unspecified; inline constexpr unspecified partial_order = unspecified; inline constexpr unspecified compare_strong_order_fallback = unspecified; inline constexpr unspecified compare_weak_order_fallback = unspecified; inline constexpr unspecified compare_partial_order_fallback = unspecified; }// [compare.type], type orderingtemplate<class T, class U>struct type_order; template<class T, class U>constexpr strong_ordering type_order_v = type_order<T, U>::value;}