blob: 350eff33882b19c33822cd7c210d16ff94ac3db4 [file] [log] [blame]
Kaido Kert788710a2023-06-05 07:50:22 -07001//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H
10#define _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H
11
12#include <__concepts/boolean_testable.h>
13#include <__concepts/equality_comparable.h>
14#include <__config>
15#include <__type_traits/common_reference.h>
16#include <__type_traits/make_const_lvalue_ref.h>
17
18#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19# pragma GCC system_header
20#endif
21
22_LIBCPP_BEGIN_NAMESPACE_STD
23
Kaido Kert56d7c4e2024-04-13 12:59:27 -070024#if _LIBCPP_STD_VER >= 20
Kaido Kert788710a2023-06-05 07:50:22 -070025
26// [concept.totallyordered]
27
28template<class _Tp, class _Up>
29concept __partially_ordered_with =
30 requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
31 { __t < __u } -> __boolean_testable;
32 { __t > __u } -> __boolean_testable;
33 { __t <= __u } -> __boolean_testable;
34 { __t >= __u } -> __boolean_testable;
35 { __u < __t } -> __boolean_testable;
36 { __u > __t } -> __boolean_testable;
37 { __u <= __t } -> __boolean_testable;
38 { __u >= __t } -> __boolean_testable;
39 };
40
41template<class _Tp>
42concept totally_ordered = equality_comparable<_Tp> && __partially_ordered_with<_Tp, _Tp>;
43
44template<class _Tp, class _Up>
45concept totally_ordered_with =
46 totally_ordered<_Tp> && totally_ordered<_Up> &&
47 equality_comparable_with<_Tp, _Up> &&
48 totally_ordered<
49 common_reference_t<
50 __make_const_lvalue_ref<_Tp>,
51 __make_const_lvalue_ref<_Up>>> &&
52 __partially_ordered_with<_Tp, _Up>;
53
Kaido Kert56d7c4e2024-04-13 12:59:27 -070054#endif // _LIBCPP_STD_VER >= 20
Kaido Kert788710a2023-06-05 07:50:22 -070055
56_LIBCPP_END_NAMESPACE_STD
57
58#endif // _LIBCPP___CONCEPTS_TOTALLY_ORDERED_H