master
  1// -*- C++ -*-
  2//===----------------------------------------------------------------------===//
  3//
  4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  5// See https://llvm.org/LICENSE.txt for license information.
  6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  7//
  8//===----------------------------------------------------------------------===//
  9
 10#ifndef _LIBCPP_COMPARE
 11#define _LIBCPP_COMPARE
 12
 13/*
 14    compare synopsis
 15
 16namespace std {
 17  // [cmp.categories], comparison category types
 18  class partial_ordering;
 19  class weak_ordering;
 20  class strong_ordering;
 21
 22  // named comparison functions
 23  constexpr bool is_eq  (partial_ordering cmp) noexcept { return cmp == 0; }
 24  constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; }
 25  constexpr bool is_lt  (partial_ordering cmp) noexcept { return cmp < 0; }
 26  constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
 27  constexpr bool is_gt  (partial_ordering cmp) noexcept { return cmp > 0; }
 28  constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
 29
 30  // [cmp.common], common comparison category type
 31  template<class... Ts>
 32  struct common_comparison_category {
 33    using type = see below;
 34  };
 35  template<class... Ts>
 36    using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
 37
 38  // [cmp.concept], concept three_way_comparable
 39  template<class T, class Cat = partial_ordering>
 40    concept three_way_comparable = see below;
 41  template<class T, class U, class Cat = partial_ordering>
 42    concept three_way_comparable_with = see below;
 43
 44  // [cmp.result], result of three-way comparison
 45  template<class T, class U = T> struct compare_three_way_result;
 46
 47  template<class T, class U = T>
 48    using compare_three_way_result_t = typename compare_three_way_result<T, U>::type;
 49
 50  // [comparisons.three.way], class compare_three_way
 51  struct compare_three_way; // C++20
 52
 53  // [cmp.alg], comparison algorithms
 54  inline namespace unspecified {
 55    inline constexpr unspecified strong_order = unspecified;
 56    inline constexpr unspecified weak_order = unspecified;
 57    inline constexpr unspecified partial_order = unspecified;
 58    inline constexpr unspecified compare_strong_order_fallback = unspecified;
 59    inline constexpr unspecified compare_weak_order_fallback = unspecified;
 60    inline constexpr unspecified compare_partial_order_fallback = unspecified;
 61  }
 62
 63  // [cmp.partialord], Class partial_ordering
 64  class partial_ordering {
 65  public:
 66    // valid values
 67    static const partial_ordering less;
 68    static const partial_ordering equivalent;
 69    static const partial_ordering greater;
 70    static const partial_ordering unordered;
 71
 72    // comparisons
 73    friend constexpr bool operator==(partial_ordering v, unspecified) noexcept;
 74    friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default;
 75    friend constexpr bool operator< (partial_ordering v, unspecified) noexcept;
 76    friend constexpr bool operator> (partial_ordering v, unspecified) noexcept;
 77    friend constexpr bool operator<=(partial_ordering v, unspecified) noexcept;
 78    friend constexpr bool operator>=(partial_ordering v, unspecified) noexcept;
 79    friend constexpr bool operator< (unspecified, partial_ordering v) noexcept;
 80    friend constexpr bool operator> (unspecified, partial_ordering v) noexcept;
 81    friend constexpr bool operator<=(unspecified, partial_ordering v) noexcept;
 82    friend constexpr bool operator>=(unspecified, partial_ordering v) noexcept;
 83    friend constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept;
 84    friend constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
 85  };
 86
 87  // [cmp.weakord], Class weak_ordering
 88  class weak_ordering {
 89  public:
 90    // valid values
 91    static const weak_ordering less;
 92    static const weak_ordering equivalent;
 93    static const weak_ordering greater;
 94
 95    // conversions
 96    constexpr operator partial_ordering() const noexcept;
 97
 98    // comparisons
 99    friend constexpr bool operator==(weak_ordering v, unspecified) noexcept;
100    friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default;
101    friend constexpr bool operator< (weak_ordering v, unspecified) noexcept;
102    friend constexpr bool operator> (weak_ordering v, unspecified) noexcept;
103    friend constexpr bool operator<=(weak_ordering v, unspecified) noexcept;
104    friend constexpr bool operator>=(weak_ordering v, unspecified) noexcept;
105    friend constexpr bool operator< (unspecified, weak_ordering v) noexcept;
106    friend constexpr bool operator> (unspecified, weak_ordering v) noexcept;
107    friend constexpr bool operator<=(unspecified, weak_ordering v) noexcept;
108    friend constexpr bool operator>=(unspecified, weak_ordering v) noexcept;
109    friend constexpr weak_ordering operator<=>(weak_ordering v, unspecified) noexcept;
110    friend constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
111  };
112
113  // [cmp.strongord], Class strong_ordering
114  class strong_ordering {
115  public:
116    // valid values
117    static const strong_ordering less;
118    static const strong_ordering equal;
119    static const strong_ordering equivalent;
120    static const strong_ordering greater;
121
122    // conversions
123    constexpr operator partial_ordering() const noexcept;
124    constexpr operator weak_ordering() const noexcept;
125
126    // comparisons
127    friend constexpr bool operator==(strong_ordering v, unspecified) noexcept;
128    friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default;
129    friend constexpr bool operator< (strong_ordering v, unspecified) noexcept;
130    friend constexpr bool operator> (strong_ordering v, unspecified) noexcept;
131    friend constexpr bool operator<=(strong_ordering v, unspecified) noexcept;
132    friend constexpr bool operator>=(strong_ordering v, unspecified) noexcept;
133    friend constexpr bool operator< (unspecified, strong_ordering v) noexcept;
134    friend constexpr bool operator> (unspecified, strong_ordering v) noexcept;
135    friend constexpr bool operator<=(unspecified, strong_ordering v) noexcept;
136    friend constexpr bool operator>=(unspecified, strong_ordering v) noexcept;
137    friend constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept;
138    friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;
139  };
140}
141*/
142
143#if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
144#  include <__cxx03/__config>
145#else
146#  include <__config>
147
148#  if _LIBCPP_STD_VER >= 20
149#    include <__compare/common_comparison_category.h>
150#    include <__compare/compare_partial_order_fallback.h>
151#    include <__compare/compare_strong_order_fallback.h>
152#    include <__compare/compare_three_way.h>
153#    include <__compare/compare_three_way_result.h>
154#    include <__compare/compare_weak_order_fallback.h>
155#    include <__compare/is_eq.h>
156#    include <__compare/ordering.h>
157#    include <__compare/partial_order.h>
158#    include <__compare/strong_order.h>
159#    include <__compare/synth_three_way.h>
160#    include <__compare/three_way_comparable.h>
161#    include <__compare/weak_order.h>
162#  endif // _LIBCPP_STD_VER >= 20
163
164#  include <version>
165
166#  if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
167#    pragma GCC system_header
168#  endif
169
170#  if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
171#    include <cmath>
172#    include <cstddef>
173#    include <type_traits>
174#  endif
175#endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
176
177#endif // _LIBCPP_COMPARE