Path: blob/main/contrib/llvm-project/libcxx/include/__compare/synth_three_way.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_SYNTH_THREE_WAY_H9#define _LIBCPP___COMPARE_SYNTH_THREE_WAY_H1011#include <__compare/ordering.h>12#include <__compare/three_way_comparable.h>13#include <__concepts/boolean_testable.h>14#include <__config>15#include <__utility/declval.h>1617#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)18# pragma GCC system_header19#endif2021_LIBCPP_BEGIN_NAMESPACE_STD2223#if _LIBCPP_STD_VER >= 202425// [expos.only.func]2627_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way = []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)28requires requires {29{ __t < __u } -> __boolean_testable;30{ __u < __t } -> __boolean_testable;31}32{33if constexpr (three_way_comparable_with<_Tp, _Up>) {34return __t <=> __u;35} else {36if (__t < __u)37return weak_ordering::less;38if (__u < __t)39return weak_ordering::greater;40return weak_ordering::equivalent;41}42};4344template <class _Tp, class _Up = _Tp>45using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));4647#endif // _LIBCPP_STD_VER >= 204849_LIBCPP_END_NAMESPACE_STD5051#endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H525354