2018-04-07 05:37:23 +08:00
|
|
|
// -*- C++ -*-
|
2021-11-18 05:25:01 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-04-07 05:37:23 +08:00
|
|
|
//
|
2019-01-19 18:56:40 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-04-07 05:37:23 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_COMPARE
|
|
|
|
#define _LIBCPP_COMPARE
|
|
|
|
|
|
|
|
/*
|
|
|
|
compare synopsis
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
// [cmp.categories], comparison category types
|
|
|
|
class partial_ordering;
|
|
|
|
class weak_ordering;
|
|
|
|
class strong_ordering;
|
|
|
|
|
|
|
|
// named comparison functions
|
2021-07-29 13:34:31 +08:00
|
|
|
constexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; }
|
|
|
|
constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; }
|
2018-04-07 05:37:23 +08:00
|
|
|
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 type
|
|
|
|
template<class... Ts>
|
|
|
|
struct common_comparison_category {
|
|
|
|
using type = see below;
|
|
|
|
};
|
|
|
|
template<class... Ts>
|
|
|
|
using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
|
|
|
|
|
2021-09-05 11:16:18 +08:00
|
|
|
// [cmp.concept], concept three_way_comparable
|
|
|
|
template<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;
|
|
|
|
|
2021-07-29 12:03:01 +08:00
|
|
|
// [cmp.result], result of three-way comparison
|
|
|
|
template<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;
|
|
|
|
|
2021-07-29 11:40:29 +08:00
|
|
|
// [comparisons.three.way], class compare_three_way
|
|
|
|
struct compare_three_way; // C++20
|
|
|
|
|
2018-04-07 05:37:23 +08:00
|
|
|
// [cmp.alg], comparison algorithms
|
|
|
|
template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
|
|
|
|
template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
|
|
|
|
template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
|
2020-06-18 22:17:57 +08:00
|
|
|
|
|
|
|
// [cmp.partialord], Class partial_ordering
|
|
|
|
class partial_ordering {
|
|
|
|
public:
|
|
|
|
// valid values
|
|
|
|
static const partial_ordering less;
|
|
|
|
static const partial_ordering equivalent;
|
|
|
|
static const partial_ordering greater;
|
|
|
|
static const partial_ordering unordered;
|
|
|
|
|
|
|
|
// comparisons
|
|
|
|
friend constexpr bool operator==(partial_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default;
|
|
|
|
friend constexpr bool operator< (partial_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator> (partial_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator<=(partial_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator>=(partial_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator< (unspecified, partial_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator> (unspecified, partial_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator<=(unspecified, partial_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator>=(unspecified, partial_ordering v) noexcept;
|
|
|
|
friend constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
// [cmp.weakord], Class weak_ordering
|
|
|
|
class weak_ordering {
|
|
|
|
public:
|
|
|
|
// valid values
|
|
|
|
static const weak_ordering less;
|
|
|
|
static const weak_ordering equivalent;
|
|
|
|
static const weak_ordering greater;
|
|
|
|
|
|
|
|
// conversions
|
|
|
|
constexpr operator partial_ordering() const noexcept;
|
|
|
|
|
|
|
|
// comparisons
|
|
|
|
friend constexpr bool operator==(weak_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default;
|
|
|
|
friend constexpr bool operator< (weak_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator> (weak_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator<=(weak_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator>=(weak_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator< (unspecified, weak_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator> (unspecified, weak_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator<=(unspecified, weak_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator>=(unspecified, weak_ordering v) noexcept;
|
|
|
|
friend constexpr weak_ordering operator<=>(weak_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
// [cmp.strongord], Class strong_ordering
|
|
|
|
class strong_ordering {
|
|
|
|
public:
|
|
|
|
// valid values
|
|
|
|
static const strong_ordering less;
|
|
|
|
static const strong_ordering equal;
|
|
|
|
static const strong_ordering equivalent;
|
|
|
|
static const strong_ordering greater;
|
|
|
|
|
|
|
|
// conversions
|
|
|
|
constexpr operator partial_ordering() const noexcept;
|
|
|
|
constexpr operator weak_ordering() const noexcept;
|
|
|
|
|
|
|
|
// comparisons
|
|
|
|
friend constexpr bool operator==(strong_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default;
|
|
|
|
friend constexpr bool operator< (strong_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator> (strong_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator<=(strong_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator>=(strong_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr bool operator< (unspecified, strong_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator> (unspecified, strong_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator<=(unspecified, strong_ordering v) noexcept;
|
|
|
|
friend constexpr bool operator>=(unspecified, strong_ordering v) noexcept;
|
|
|
|
friend constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept;
|
|
|
|
friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;
|
|
|
|
};
|
2018-04-07 05:37:23 +08:00
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
2021-07-29 10:05:46 +08:00
|
|
|
#include <__compare/common_comparison_category.h>
|
2021-07-29 11:40:29 +08:00
|
|
|
#include <__compare/compare_three_way.h>
|
2021-07-29 12:03:01 +08:00
|
|
|
#include <__compare/compare_three_way_result.h>
|
2021-09-27 12:48:39 +08:00
|
|
|
#include <__compare/is_eq.h>
|
2021-07-29 10:05:46 +08:00
|
|
|
#include <__compare/ordering.h>
|
2021-07-29 10:04:18 +08:00
|
|
|
#include <__compare/partial_order.h>
|
|
|
|
#include <__compare/strong_order.h>
|
2021-09-05 11:16:18 +08:00
|
|
|
#include <__compare/three_way_comparable.h>
|
2021-07-29 10:04:18 +08:00
|
|
|
#include <__compare/weak_order.h>
|
2018-04-07 05:37:23 +08:00
|
|
|
#include <__config>
|
2021-12-23 01:14:14 +08:00
|
|
|
#include <version>
|
2018-04-07 05:37:23 +08:00
|
|
|
|
2021-12-06 02:08:36 +08:00
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
|
|
#pragma GCC system_header
|
|
|
|
#endif
|
|
|
|
|
2018-04-07 05:37:23 +08:00
|
|
|
#endif // _LIBCPP_COMPARE
|