Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-03 08:13:16

0001 //===----------------------------------------------------------------------===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 
0009 #ifndef _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
0010 #define _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
0011 
0012 #include <__compare/ordering.h>
0013 #include <__compare/three_way_comparable.h>
0014 #include <__concepts/boolean_testable.h>
0015 #include <__config>
0016 #include <__utility/declval.h>
0017 
0018 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
0019 #  pragma GCC system_header
0020 #endif
0021 
0022 _LIBCPP_BEGIN_NAMESPACE_STD
0023 
0024 #if _LIBCPP_STD_VER >= 20
0025 
0026 // [expos.only.func]
0027 
0028 _LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
0029   requires requires {
0030     { __t < __u } -> __boolean_testable;
0031     { __u < __t } -> __boolean_testable;
0032   }
0033 {
0034   if constexpr (three_way_comparable_with<_Tp, _Up>) {
0035     return __t <=> __u;
0036   } else {
0037     if (__t < __u)
0038       return weak_ordering::less;
0039     if (__u < __t)
0040       return weak_ordering::greater;
0041     return weak_ordering::equivalent;
0042   }
0043 };
0044 
0045 template <class _Tp, class _Up = _Tp>
0046 using __synth_three_way_result _LIBCPP_NODEBUG =
0047     decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
0048 
0049 #endif // _LIBCPP_STD_VER >= 20
0050 
0051 _LIBCPP_END_NAMESPACE_STD
0052 
0053 #endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H