Warning, /include/c++/v1/compare is written in an unsupported language. File is not indexed.
0001 // -*- C++ -*-
0002 //===----------------------------------------------------------------------===//
0003 //
0004 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0005 // See https://llvm.org/LICENSE.txt for license information.
0006 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0007 //
0008 //===----------------------------------------------------------------------===//
0009
0010 #ifndef _LIBCPP_COMPARE
0011 #define _LIBCPP_COMPARE
0012
0013 /*
0014 compare synopsis
0015
0016 namespace std {
0017 // [cmp.categories], comparison category types
0018 class partial_ordering;
0019 class weak_ordering;
0020 class strong_ordering;
0021
0022 // named comparison functions
0023 constexpr bool is_eq (partial_ordering cmp) noexcept { return cmp == 0; }
0024 constexpr bool is_neq (partial_ordering cmp) noexcept { return cmp != 0; }
0025 constexpr bool is_lt (partial_ordering cmp) noexcept { return cmp < 0; }
0026 constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
0027 constexpr bool is_gt (partial_ordering cmp) noexcept { return cmp > 0; }
0028 constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
0029
0030 // [cmp.common], common comparison category type
0031 template<class... Ts>
0032 struct common_comparison_category {
0033 using type = see below;
0034 };
0035 template<class... Ts>
0036 using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
0037
0038 // [cmp.concept], concept three_way_comparable
0039 template<class T, class Cat = partial_ordering>
0040 concept three_way_comparable = see below;
0041 template<class T, class U, class Cat = partial_ordering>
0042 concept three_way_comparable_with = see below;
0043
0044 // [cmp.result], result of three-way comparison
0045 template<class T, class U = T> struct compare_three_way_result;
0046
0047 template<class T, class U = T>
0048 using compare_three_way_result_t = typename compare_three_way_result<T, U>::type;
0049
0050 // [comparisons.three.way], class compare_three_way
0051 struct compare_three_way; // C++20
0052
0053 // [cmp.alg], comparison algorithms
0054 inline namespace unspecified {
0055 inline constexpr unspecified strong_order = unspecified;
0056 inline constexpr unspecified weak_order = unspecified;
0057 inline constexpr unspecified partial_order = unspecified;
0058 inline constexpr unspecified compare_strong_order_fallback = unspecified;
0059 inline constexpr unspecified compare_weak_order_fallback = unspecified;
0060 inline constexpr unspecified compare_partial_order_fallback = unspecified;
0061 }
0062
0063 // [cmp.partialord], Class partial_ordering
0064 class partial_ordering {
0065 public:
0066 // valid values
0067 static const partial_ordering less;
0068 static const partial_ordering equivalent;
0069 static const partial_ordering greater;
0070 static const partial_ordering unordered;
0071
0072 // comparisons
0073 friend constexpr bool operator==(partial_ordering v, unspecified) noexcept;
0074 friend constexpr bool operator==(partial_ordering v, partial_ordering w) noexcept = default;
0075 friend constexpr bool operator< (partial_ordering v, unspecified) noexcept;
0076 friend constexpr bool operator> (partial_ordering v, unspecified) noexcept;
0077 friend constexpr bool operator<=(partial_ordering v, unspecified) noexcept;
0078 friend constexpr bool operator>=(partial_ordering v, unspecified) noexcept;
0079 friend constexpr bool operator< (unspecified, partial_ordering v) noexcept;
0080 friend constexpr bool operator> (unspecified, partial_ordering v) noexcept;
0081 friend constexpr bool operator<=(unspecified, partial_ordering v) noexcept;
0082 friend constexpr bool operator>=(unspecified, partial_ordering v) noexcept;
0083 friend constexpr partial_ordering operator<=>(partial_ordering v, unspecified) noexcept;
0084 friend constexpr partial_ordering operator<=>(unspecified, partial_ordering v) noexcept;
0085 };
0086
0087 // [cmp.weakord], Class weak_ordering
0088 class weak_ordering {
0089 public:
0090 // valid values
0091 static const weak_ordering less;
0092 static const weak_ordering equivalent;
0093 static const weak_ordering greater;
0094
0095 // conversions
0096 constexpr operator partial_ordering() const noexcept;
0097
0098 // comparisons
0099 friend constexpr bool operator==(weak_ordering v, unspecified) noexcept;
0100 friend constexpr bool operator==(weak_ordering v, weak_ordering w) noexcept = default;
0101 friend constexpr bool operator< (weak_ordering v, unspecified) noexcept;
0102 friend constexpr bool operator> (weak_ordering v, unspecified) noexcept;
0103 friend constexpr bool operator<=(weak_ordering v, unspecified) noexcept;
0104 friend constexpr bool operator>=(weak_ordering v, unspecified) noexcept;
0105 friend constexpr bool operator< (unspecified, weak_ordering v) noexcept;
0106 friend constexpr bool operator> (unspecified, weak_ordering v) noexcept;
0107 friend constexpr bool operator<=(unspecified, weak_ordering v) noexcept;
0108 friend constexpr bool operator>=(unspecified, weak_ordering v) noexcept;
0109 friend constexpr weak_ordering operator<=>(weak_ordering v, unspecified) noexcept;
0110 friend constexpr weak_ordering operator<=>(unspecified, weak_ordering v) noexcept;
0111 };
0112
0113 // [cmp.strongord], Class strong_ordering
0114 class strong_ordering {
0115 public:
0116 // valid values
0117 static const strong_ordering less;
0118 static const strong_ordering equal;
0119 static const strong_ordering equivalent;
0120 static const strong_ordering greater;
0121
0122 // conversions
0123 constexpr operator partial_ordering() const noexcept;
0124 constexpr operator weak_ordering() const noexcept;
0125
0126 // comparisons
0127 friend constexpr bool operator==(strong_ordering v, unspecified) noexcept;
0128 friend constexpr bool operator==(strong_ordering v, strong_ordering w) noexcept = default;
0129 friend constexpr bool operator< (strong_ordering v, unspecified) noexcept;
0130 friend constexpr bool operator> (strong_ordering v, unspecified) noexcept;
0131 friend constexpr bool operator<=(strong_ordering v, unspecified) noexcept;
0132 friend constexpr bool operator>=(strong_ordering v, unspecified) noexcept;
0133 friend constexpr bool operator< (unspecified, strong_ordering v) noexcept;
0134 friend constexpr bool operator> (unspecified, strong_ordering v) noexcept;
0135 friend constexpr bool operator<=(unspecified, strong_ordering v) noexcept;
0136 friend constexpr bool operator>=(unspecified, strong_ordering v) noexcept;
0137 friend constexpr strong_ordering operator<=>(strong_ordering v, unspecified) noexcept;
0138 friend constexpr strong_ordering operator<=>(unspecified, strong_ordering v) noexcept;
0139 };
0140 }
0141 */
0142
0143 #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0144 # include <__cxx03/compare>
0145 #else
0146 # include <__config>
0147
0148 # if _LIBCPP_STD_VER >= 20
0149 # include <__compare/common_comparison_category.h>
0150 # include <__compare/compare_partial_order_fallback.h>
0151 # include <__compare/compare_strong_order_fallback.h>
0152 # include <__compare/compare_three_way.h>
0153 # include <__compare/compare_three_way_result.h>
0154 # include <__compare/compare_weak_order_fallback.h>
0155 # include <__compare/is_eq.h>
0156 # include <__compare/ordering.h>
0157 # include <__compare/partial_order.h>
0158 # include <__compare/strong_order.h>
0159 # include <__compare/synth_three_way.h>
0160 # include <__compare/three_way_comparable.h>
0161 # include <__compare/weak_order.h>
0162 # endif // _LIBCPP_STD_VER >= 20
0163
0164 # include <version>
0165
0166 # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0167 # pragma GCC system_header
0168 # endif
0169
0170 # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
0171 # include <cmath>
0172 # include <cstddef>
0173 # include <type_traits>
0174 # endif
0175 #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS)
0176
0177 #endif // _LIBCPP_COMPARE