Path: blob/main/contrib/llvm-project/libcxx/include/__compare/partial_order.h
35262 views
//===----------------------------------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef _LIBCPP___COMPARE_PARTIAL_ORDER9#define _LIBCPP___COMPARE_PARTIAL_ORDER1011#include <__compare/compare_three_way.h>12#include <__compare/ordering.h>13#include <__compare/weak_order.h>14#include <__config>15#include <__type_traits/decay.h>16#include <__type_traits/is_same.h>17#include <__utility/forward.h>18#include <__utility/priority_tag.h>1920#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER21# pragma GCC system_header22#endif2324_LIBCPP_BEGIN_NAMESPACE_STD2526#if _LIBCPP_STD_VER >= 202728// [cmp.alg]29namespace __partial_order {30void partial_order() = delete;3132struct __fn {33// NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here34template <class _Tp, class _Up>35requires is_same_v<decay_t<_Tp>, decay_t<_Up>>36_LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept(37noexcept(partial_ordering(partial_order(std::forward<_Tp>(__t), std::forward<_Up>(__u)))))38-> decltype(partial_ordering(partial_order(std::forward<_Tp>(__t), std::forward<_Up>(__u)))) {39return partial_ordering(partial_order(std::forward<_Tp>(__t), std::forward<_Up>(__u)));40}41// NOLINTEND(libcpp-robust-against-adl)4243template <class _Tp, class _Up>44requires is_same_v<decay_t<_Tp>, decay_t<_Up>>45_LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept(46noexcept(partial_ordering(compare_three_way()(std::forward<_Tp>(__t), std::forward<_Up>(__u)))))47-> decltype(partial_ordering(compare_three_way()(std::forward<_Tp>(__t), std::forward<_Up>(__u)))) {48return partial_ordering(compare_three_way()(std::forward<_Tp>(__t), std::forward<_Up>(__u)));49}5051template <class _Tp, class _Up>52requires is_same_v<decay_t<_Tp>, decay_t<_Up>>53_LIBCPP_HIDE_FROM_ABI static constexpr auto __go(_Tp&& __t, _Up&& __u, __priority_tag<0>) noexcept(54noexcept(partial_ordering(std::weak_order(std::forward<_Tp>(__t), std::forward<_Up>(__u)))))55-> decltype(partial_ordering(std::weak_order(std::forward<_Tp>(__t), std::forward<_Up>(__u)))) {56return partial_ordering(std::weak_order(std::forward<_Tp>(__t), std::forward<_Up>(__u)));57}5859template <class _Tp, class _Up>60_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const61noexcept(noexcept(__go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<2>())))62-> decltype(__go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<2>())) {63return __go(std::forward<_Tp>(__t), std::forward<_Up>(__u), __priority_tag<2>());64}65};66} // namespace __partial_order6768inline namespace __cpo {69inline constexpr auto partial_order = __partial_order::__fn{};70} // namespace __cpo7172#endif // _LIBCPP_STD_VER >= 207374_LIBCPP_END_NAMESPACE_STD7576#endif // _LIBCPP___COMPARE_PARTIAL_ORDER777879