1 //===----------------------------------------------------------------------===//
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___COMPARE_PARTIAL_ORDER
10 #define _LIBCPP___COMPARE_PARTIAL_ORDER
11 
12 #include <__compare/compare_three_way.h>
13 #include <__compare/ordering.h>
14 #include <__compare/weak_order.h>
15 #include <__config>
16 #include <__utility/forward.h>
17 #include <__utility/priority_tag.h>
18 #include <type_traits>
19 
20 #ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
21 #pragma GCC system_header
22 #endif
23 
24 _LIBCPP_BEGIN_NAMESPACE_STD
25 
26 #if !defined(_LIBCPP_HAS_NO_CONCEPTS)
27 
28 // [cmp.alg]
29 namespace __partial_order {
30     struct __fn {
31         template<class _Tp, class _Up>
32             requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
33         _LIBCPP_HIDE_FROM_ABI static constexpr auto
34         __go(_Tp&& __t, _Up&& __u, __priority_tag<2>)
35             noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
36             -> decltype(      partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
37             { return          partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
38 
39         template<class _Tp, class _Up>
40             requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
41         _LIBCPP_HIDE_FROM_ABI static constexpr auto
42         __go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
43             noexcept(noexcept(partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
44             -> decltype(      partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
45             { return          partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
46 
47         template<class _Tp, class _Up>
48             requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
49         _LIBCPP_HIDE_FROM_ABI static constexpr auto
50         __go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
51             noexcept(noexcept(partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
52             -> decltype(      partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
53             { return          partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
54 
55         template<class _Tp, class _Up>
56         _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
57             noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())))
58             -> decltype(      __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))
59             { return          __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); }
60     };
61 } // namespace __partial_order
62 
63 inline namespace __cpo {
64     inline constexpr auto partial_order = __partial_order::__fn{};
65 } // namespace __cpo
66 
67 #endif // !defined(_LIBCPP_HAS_NO_CONCEPTS)
68 
69 _LIBCPP_END_NAMESPACE_STD
70 
71 #endif // _LIBCPP___COMPARE_PARTIAL_ORDER
72