mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-30 08:18:30 +00:00
Upgrade to 2022-era LLVM LIBCXX
This commit is contained in:
parent
2f4ca71f26
commit
8e68384e15
2078 changed files with 165657 additions and 65010 deletions
95
third_party/libcxx/__compare/common_comparison_category.h
vendored
Normal file
95
third_party/libcxx/__compare/common_comparison_category.h
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H
|
||||
#define _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H
|
||||
|
||||
#include <__compare/ordering.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/is_same.h>
|
||||
#include <cstddef>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
namespace __comp_detail {
|
||||
|
||||
enum _ClassifyCompCategory : unsigned {
|
||||
_None,
|
||||
_PartialOrd,
|
||||
_WeakOrd,
|
||||
_StrongOrd,
|
||||
_CCC_Size
|
||||
};
|
||||
|
||||
template <class _Tp>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr _ClassifyCompCategory __type_to_enum() noexcept {
|
||||
if (is_same_v<_Tp, partial_ordering>)
|
||||
return _PartialOrd;
|
||||
if (is_same_v<_Tp, weak_ordering>)
|
||||
return _WeakOrd;
|
||||
if (is_same_v<_Tp, strong_ordering>)
|
||||
return _StrongOrd;
|
||||
return _None;
|
||||
}
|
||||
|
||||
template <size_t _Size>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr _ClassifyCompCategory
|
||||
__compute_comp_type(const _ClassifyCompCategory (&__types)[_Size]) {
|
||||
int __seen[_CCC_Size] = {};
|
||||
for (auto __type : __types)
|
||||
++__seen[__type];
|
||||
if (__seen[_None])
|
||||
return _None;
|
||||
if (__seen[_PartialOrd])
|
||||
return _PartialOrd;
|
||||
if (__seen[_WeakOrd])
|
||||
return _WeakOrd;
|
||||
return _StrongOrd;
|
||||
}
|
||||
|
||||
template <class ..._Ts, bool _False = false>
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr auto __get_comp_type() {
|
||||
using _CCC = _ClassifyCompCategory;
|
||||
constexpr _CCC __type_kinds[] = {_StrongOrd, __type_to_enum<_Ts>()...};
|
||||
constexpr _CCC __cat = __comp_detail::__compute_comp_type(__type_kinds);
|
||||
if constexpr (__cat == _None)
|
||||
return void();
|
||||
else if constexpr (__cat == _PartialOrd)
|
||||
return partial_ordering::equivalent;
|
||||
else if constexpr (__cat == _WeakOrd)
|
||||
return weak_ordering::equivalent;
|
||||
else if constexpr (__cat == _StrongOrd)
|
||||
return strong_ordering::equivalent;
|
||||
else
|
||||
static_assert(_False, "unhandled case");
|
||||
}
|
||||
} // namespace __comp_detail
|
||||
|
||||
// [cmp.common], common comparison category type
|
||||
template<class... _Ts>
|
||||
struct _LIBCPP_TEMPLATE_VIS common_comparison_category {
|
||||
using type = decltype(__comp_detail::__get_comp_type<_Ts...>());
|
||||
};
|
||||
|
||||
template<class... _Ts>
|
||||
using common_comparison_category_t = typename common_comparison_category<_Ts...>::type;
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_COMMON_COMPARISON_CATEGORY_H
|
74
third_party/libcxx/__compare/compare_partial_order_fallback.h
vendored
Normal file
74
third_party/libcxx/__compare/compare_partial_order_fallback.h
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
|
||||
#define _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
|
||||
|
||||
#include <__compare/ordering.h>
|
||||
#include <__compare/partial_order.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/decay.h>
|
||||
#include <__type_traits/is_same.h>
|
||||
#include <__utility/forward.h>
|
||||
#include <__utility/priority_tag.h>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// [cmp.alg]
|
||||
namespace __compare_partial_order_fallback {
|
||||
struct __fn {
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
|
||||
noexcept(noexcept(_VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
-> decltype( _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))
|
||||
{ return _VSTD::partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
|
||||
noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less :
|
||||
_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater :
|
||||
partial_ordering::unordered))
|
||||
-> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less :
|
||||
_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater :
|
||||
partial_ordering::unordered)
|
||||
{
|
||||
return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? partial_ordering::equivalent :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? partial_ordering::less :
|
||||
_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t) ? partial_ordering::greater :
|
||||
partial_ordering::unordered;
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
|
||||
noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())))
|
||||
-> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))
|
||||
{ return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); }
|
||||
};
|
||||
} // namespace __compare_partial_order_fallback
|
||||
|
||||
inline namespace __cpo {
|
||||
inline constexpr auto compare_partial_order_fallback = __compare_partial_order_fallback::__fn{};
|
||||
} // namespace __cpo
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_COMPARE_PARTIAL_ORDER_FALLBACK
|
71
third_party/libcxx/__compare/compare_strong_order_fallback.h
vendored
Normal file
71
third_party/libcxx/__compare/compare_strong_order_fallback.h
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK
|
||||
#define _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK
|
||||
|
||||
#include <__compare/ordering.h>
|
||||
#include <__compare/strong_order.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/decay.h>
|
||||
#include <__type_traits/is_same.h>
|
||||
#include <__utility/forward.h>
|
||||
#include <__utility/priority_tag.h>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// [cmp.alg]
|
||||
namespace __compare_strong_order_fallback {
|
||||
struct __fn {
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
|
||||
noexcept(noexcept(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
-> decltype( _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))
|
||||
{ return _VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
|
||||
noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less :
|
||||
strong_ordering::greater))
|
||||
-> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less :
|
||||
strong_ordering::greater)
|
||||
{
|
||||
return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? strong_ordering::equal :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? strong_ordering::less :
|
||||
strong_ordering::greater;
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
|
||||
noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())))
|
||||
-> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))
|
||||
{ return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); }
|
||||
};
|
||||
} // namespace __compare_strong_order_fallback
|
||||
|
||||
inline namespace __cpo {
|
||||
inline constexpr auto compare_strong_order_fallback = __compare_strong_order_fallback::__fn{};
|
||||
} // namespace __cpo
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_COMPARE_STRONG_ORDER_FALLBACK
|
41
third_party/libcxx/__compare/compare_three_way.h
vendored
Normal file
41
third_party/libcxx/__compare/compare_three_way.h
vendored
Normal file
|
@ -0,0 +1,41 @@
|
|||
// -*- C++ -*-
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_COMPARE_THREE_WAY_H
|
||||
#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_H
|
||||
|
||||
#include <__compare/three_way_comparable.h>
|
||||
#include <__config>
|
||||
#include <__utility/forward.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
struct _LIBCPP_TEMPLATE_VIS compare_three_way
|
||||
{
|
||||
template<class _T1, class _T2>
|
||||
requires three_way_comparable_with<_T1, _T2>
|
||||
constexpr _LIBCPP_HIDE_FROM_ABI
|
||||
auto operator()(_T1&& __t, _T2&& __u) const
|
||||
noexcept(noexcept(_VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u)))
|
||||
{ return _VSTD::forward<_T1>(__t) <=> _VSTD::forward<_T2>(__u); }
|
||||
|
||||
using is_transparent = void;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_H
|
44
third_party/libcxx/__compare/compare_three_way_result.h
vendored
Normal file
44
third_party/libcxx/__compare/compare_three_way_result.h
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
|
||||
#define _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
|
||||
|
||||
#include <__config>
|
||||
#include <__type_traits/make_const_lvalue_ref.h>
|
||||
#include <__utility/declval.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
template<class, class, class>
|
||||
struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result { };
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
struct _LIBCPP_HIDE_FROM_ABI __compare_three_way_result<_Tp, _Up, decltype(
|
||||
std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>(), void()
|
||||
)> {
|
||||
using type = decltype(std::declval<__make_const_lvalue_ref<_Tp>>() <=> std::declval<__make_const_lvalue_ref<_Up>>());
|
||||
};
|
||||
|
||||
template<class _Tp, class _Up = _Tp>
|
||||
struct _LIBCPP_TEMPLATE_VIS compare_three_way_result : __compare_three_way_result<_Tp, _Up, void> { };
|
||||
|
||||
template<class _Tp, class _Up = _Tp>
|
||||
using compare_three_way_result_t = typename compare_three_way_result<_Tp, _Up>::type;
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_COMPARE_THREE_WAY_RESULT_H
|
71
third_party/libcxx/__compare/compare_weak_order_fallback.h
vendored
Normal file
71
third_party/libcxx/__compare/compare_weak_order_fallback.h
vendored
Normal file
|
@ -0,0 +1,71 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK
|
||||
#define _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK
|
||||
|
||||
#include <__compare/ordering.h>
|
||||
#include <__compare/weak_order.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/decay.h>
|
||||
#include <__type_traits/is_same.h>
|
||||
#include <__utility/forward.h>
|
||||
#include <__utility/priority_tag.h>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// [cmp.alg]
|
||||
namespace __compare_weak_order_fallback {
|
||||
struct __fn {
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
|
||||
noexcept(noexcept(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
-> decltype( _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))
|
||||
{ return _VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
|
||||
noexcept(noexcept(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less :
|
||||
weak_ordering::greater))
|
||||
-> decltype( _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less :
|
||||
weak_ordering::greater)
|
||||
{
|
||||
return _VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u) ? weak_ordering::equivalent :
|
||||
_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u) ? weak_ordering::less :
|
||||
weak_ordering::greater;
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
|
||||
noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>())))
|
||||
-> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()))
|
||||
{ return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<1>()); }
|
||||
};
|
||||
} // namespace __compare_weak_order_fallback
|
||||
|
||||
inline namespace __cpo {
|
||||
inline constexpr auto compare_weak_order_fallback = __compare_weak_order_fallback::__fn{};
|
||||
} // namespace __cpo
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_COMPARE_WEAK_ORDER_FALLBACK
|
34
third_party/libcxx/__compare/is_eq.h
vendored
Normal file
34
third_party/libcxx/__compare/is_eq.h
vendored
Normal file
|
@ -0,0 +1,34 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_IS_EQ_H
|
||||
#define _LIBCPP___COMPARE_IS_EQ_H
|
||||
|
||||
#include <__compare/ordering.h>
|
||||
#include <__config>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_eq(partial_ordering __c) noexcept { return __c == 0; }
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_neq(partial_ordering __c) noexcept { return __c != 0; }
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lt(partial_ordering __c) noexcept { return __c < 0; }
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_lteq(partial_ordering __c) noexcept { return __c <= 0; }
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gt(partial_ordering __c) noexcept { return __c > 0; }
|
||||
_LIBCPP_HIDE_FROM_ABI inline constexpr bool is_gteq(partial_ordering __c) noexcept { return __c >= 0; }
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_IS_EQ_H
|
326
third_party/libcxx/__compare/ordering.h
vendored
Normal file
326
third_party/libcxx/__compare/ordering.h
vendored
Normal file
|
@ -0,0 +1,326 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_ORDERING_H
|
||||
#define _LIBCPP___COMPARE_ORDERING_H
|
||||
|
||||
#include <__config>
|
||||
#include <__type_traits/enable_if.h>
|
||||
#include <__type_traits/is_same.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// exposition only
|
||||
enum class _LIBCPP_ENUM_VIS _OrdResult : signed char {
|
||||
__less = -1,
|
||||
__equiv = 0,
|
||||
__greater = 1
|
||||
};
|
||||
|
||||
enum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
|
||||
__unordered = -127
|
||||
};
|
||||
|
||||
class partial_ordering;
|
||||
class weak_ordering;
|
||||
class strong_ordering;
|
||||
|
||||
template<class _Tp, class... _Args>
|
||||
inline constexpr bool __one_of_v = (is_same_v<_Tp, _Args> || ...);
|
||||
|
||||
struct _CmpUnspecifiedParam {
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr
|
||||
_CmpUnspecifiedParam(int _CmpUnspecifiedParam::*) noexcept {}
|
||||
|
||||
template<class _Tp, class = enable_if_t<!__one_of_v<_Tp, int, partial_ordering, weak_ordering, strong_ordering>>>
|
||||
_CmpUnspecifiedParam(_Tp) = delete;
|
||||
};
|
||||
|
||||
class partial_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
explicit constexpr partial_ordering(_OrdResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
explicit constexpr partial_ordering(_NCmpResult __v) noexcept
|
||||
: __value_(_ValueT(__v)) {}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr bool __is_ordered() const noexcept {
|
||||
return __value_ != _ValueT(_NCmpResult::__unordered);
|
||||
}
|
||||
public:
|
||||
// valid values
|
||||
static const partial_ordering less;
|
||||
static const partial_ordering equivalent;
|
||||
static const partial_ordering greater;
|
||||
static const partial_ordering unordered;
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default;
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ == 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ < 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ <= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ > 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__is_ordered() && __v.__value_ >= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 < __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 <= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 > __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v.__is_ordered() && 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
|
||||
return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
|
||||
}
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
|
||||
inline constexpr partial_ordering partial_ordering::equivalent(_OrdResult::__equiv);
|
||||
inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
|
||||
inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
|
||||
|
||||
class weak_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
|
||||
public:
|
||||
static const weak_ordering less;
|
||||
static const weak_ordering equivalent;
|
||||
static const weak_ordering greater;
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr operator partial_ordering() const noexcept {
|
||||
return __value_ == 0 ? partial_ordering::equivalent
|
||||
: (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default;
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ < 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ <= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ > 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ >= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 < __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 <= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 > __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
|
||||
return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
|
||||
}
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
inline constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
|
||||
inline constexpr weak_ordering weak_ordering::equivalent(_OrdResult::__equiv);
|
||||
inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
|
||||
|
||||
class strong_ordering {
|
||||
using _ValueT = signed char;
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
|
||||
|
||||
public:
|
||||
static const strong_ordering less;
|
||||
static const strong_ordering equal;
|
||||
static const strong_ordering equivalent;
|
||||
static const strong_ordering greater;
|
||||
|
||||
// conversions
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr operator partial_ordering() const noexcept {
|
||||
return __value_ == 0 ? partial_ordering::equivalent
|
||||
: (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
constexpr operator weak_ordering() const noexcept {
|
||||
return __value_ == 0 ? weak_ordering::equivalent
|
||||
: (__value_ < 0 ? weak_ordering::less : weak_ordering::greater);
|
||||
}
|
||||
|
||||
// comparisons
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default;
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ == 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ < 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ <= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ > 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v.__value_ >= 0;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 < __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 <= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 > __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return 0 >= __v.__value_;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
|
||||
return __v;
|
||||
}
|
||||
|
||||
_LIBCPP_HIDE_FROM_ABI
|
||||
friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
|
||||
return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
|
||||
}
|
||||
|
||||
private:
|
||||
_ValueT __value_;
|
||||
};
|
||||
|
||||
inline constexpr strong_ordering strong_ordering::less(_OrdResult::__less);
|
||||
inline constexpr strong_ordering strong_ordering::equal(_OrdResult::__equiv);
|
||||
inline constexpr strong_ordering strong_ordering::equivalent(_OrdResult::__equiv);
|
||||
inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
|
||||
|
||||
/// [cmp.categories.pre]/1
|
||||
/// The types partial_ordering, weak_ordering, and strong_ordering are
|
||||
/// collectively termed the comparison category types.
|
||||
template <class _Tp>
|
||||
concept __comparison_category = __one_of_v<_Tp, partial_ordering, weak_ordering, strong_ordering>;
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_ORDERING_H
|
74
third_party/libcxx/__compare/partial_order.h
vendored
Normal file
74
third_party/libcxx/__compare/partial_order.h
vendored
Normal file
|
@ -0,0 +1,74 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_PARTIAL_ORDER
|
||||
#define _LIBCPP___COMPARE_PARTIAL_ORDER
|
||||
|
||||
#include <__compare/compare_three_way.h>
|
||||
#include <__compare/ordering.h>
|
||||
#include <__compare/weak_order.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/decay.h>
|
||||
#include <__type_traits/is_same.h>
|
||||
#include <__utility/forward.h>
|
||||
#include <__utility/priority_tag.h>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// [cmp.alg]
|
||||
namespace __partial_order {
|
||||
struct __fn {
|
||||
// NOLINTBEGIN(libcpp-robust-against-adl) partial_order should use ADL, but only here
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<2>)
|
||||
noexcept(noexcept(partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return partial_ordering(partial_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
// NOLINTEND(libcpp-robust-against-adl)
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
|
||||
noexcept(noexcept(partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return partial_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
|
||||
noexcept(noexcept(partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return partial_ordering(_VSTD::weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
|
||||
noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())))
|
||||
-> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))
|
||||
{ return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); }
|
||||
};
|
||||
} // namespace __partial_order
|
||||
|
||||
inline namespace __cpo {
|
||||
inline constexpr auto partial_order = __partial_order::__fn{};
|
||||
} // namespace __cpo
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_PARTIAL_ORDER
|
139
third_party/libcxx/__compare/strong_order.h
vendored
Normal file
139
third_party/libcxx/__compare/strong_order.h
vendored
Normal file
|
@ -0,0 +1,139 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_STRONG_ORDER
|
||||
#define _LIBCPP___COMPARE_STRONG_ORDER
|
||||
|
||||
#include <__bit/bit_cast.h>
|
||||
#include <__compare/compare_three_way.h>
|
||||
#include <__compare/ordering.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/conditional.h>
|
||||
#include <__type_traits/decay.h>
|
||||
#include <__utility/forward.h>
|
||||
#include <__utility/priority_tag.h>
|
||||
#include <cmath>
|
||||
#include <cstdint>
|
||||
#include <limits>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_PUSH_MACROS
|
||||
#include <__undef_macros>
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// [cmp.alg]
|
||||
namespace __strong_order {
|
||||
struct __fn {
|
||||
// NOLINTBEGIN(libcpp-robust-against-adl) strong_order should use ADL, but only here
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<2>)
|
||||
noexcept(noexcept(strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return strong_ordering(strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
// NOLINTEND(libcpp-robust-against-adl)
|
||||
|
||||
template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
|
||||
requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr strong_ordering
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<1>) noexcept
|
||||
{
|
||||
if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int32_t)) {
|
||||
int32_t __rx = _VSTD::bit_cast<int32_t>(__t);
|
||||
int32_t __ry = _VSTD::bit_cast<int32_t>(__u);
|
||||
__rx = (__rx < 0) ? (numeric_limits<int32_t>::min() - __rx - 1) : __rx;
|
||||
__ry = (__ry < 0) ? (numeric_limits<int32_t>::min() - __ry - 1) : __ry;
|
||||
return (__rx <=> __ry);
|
||||
} else if constexpr (numeric_limits<_Dp>::is_iec559 && sizeof(_Dp) == sizeof(int64_t)) {
|
||||
int64_t __rx = _VSTD::bit_cast<int64_t>(__t);
|
||||
int64_t __ry = _VSTD::bit_cast<int64_t>(__u);
|
||||
__rx = (__rx < 0) ? (numeric_limits<int64_t>::min() - __rx - 1) : __rx;
|
||||
__ry = (__ry < 0) ? (numeric_limits<int64_t>::min() - __ry - 1) : __ry;
|
||||
return (__rx <=> __ry);
|
||||
} else if (__t < __u) {
|
||||
return strong_ordering::less;
|
||||
} else if (__t > __u) {
|
||||
return strong_ordering::greater;
|
||||
} else if (__t == __u) {
|
||||
if constexpr (numeric_limits<_Dp>::radix == 2) {
|
||||
return _VSTD::signbit(__u) <=> _VSTD::signbit(__t);
|
||||
} else {
|
||||
// This is bullet 3 of the IEEE754 algorithm, relevant
|
||||
// only for decimal floating-point;
|
||||
// see https://stackoverflow.com/questions/69068075/
|
||||
if (__t == 0 || _VSTD::isinf(__t)) {
|
||||
return _VSTD::signbit(__u) <=> _VSTD::signbit(__t);
|
||||
} else {
|
||||
int __texp, __uexp;
|
||||
(void)_VSTD::frexp(__t, &__texp);
|
||||
(void)_VSTD::frexp(__u, &__uexp);
|
||||
return (__t < 0) ? (__texp <=> __uexp) : (__uexp <=> __texp);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// They're unordered, so one of them must be a NAN.
|
||||
// The order is -QNAN, -SNAN, numbers, +SNAN, +QNAN.
|
||||
bool __t_is_nan = _VSTD::isnan(__t);
|
||||
bool __u_is_nan = _VSTD::isnan(__u);
|
||||
bool __t_is_negative = _VSTD::signbit(__t);
|
||||
bool __u_is_negative = _VSTD::signbit(__u);
|
||||
using _IntType = conditional_t<
|
||||
sizeof(__t) == sizeof(int32_t), int32_t, conditional_t<
|
||||
sizeof(__t) == sizeof(int64_t), int64_t, void>
|
||||
>;
|
||||
if constexpr (is_same_v<_IntType, void>) {
|
||||
static_assert(sizeof(_Dp) == 0, "std::strong_order is unimplemented for this floating-point type");
|
||||
} else if (__t_is_nan && __u_is_nan) {
|
||||
// Order by sign bit, then by "payload bits" (we'll just use bit_cast).
|
||||
if (__t_is_negative != __u_is_negative) {
|
||||
return (__u_is_negative <=> __t_is_negative);
|
||||
} else {
|
||||
return _VSTD::bit_cast<_IntType>(__t) <=> _VSTD::bit_cast<_IntType>(__u);
|
||||
}
|
||||
} else if (__t_is_nan) {
|
||||
return __t_is_negative ? strong_ordering::less : strong_ordering::greater;
|
||||
} else {
|
||||
return __u_is_negative ? strong_ordering::greater : strong_ordering::less;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
|
||||
noexcept(noexcept(strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return strong_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
|
||||
noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>())))
|
||||
-> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()))
|
||||
{ return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<2>()); }
|
||||
};
|
||||
} // namespace __strong_order
|
||||
|
||||
inline namespace __cpo {
|
||||
inline constexpr auto strong_order = __strong_order::__fn{};
|
||||
} // namespace __cpo
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
_LIBCPP_POP_MACROS
|
||||
|
||||
#endif // _LIBCPP___COMPARE_STRONG_ORDER
|
57
third_party/libcxx/__compare/synth_three_way.h
vendored
Normal file
57
third_party/libcxx/__compare/synth_three_way.h
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
|
||||
#define _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
|
||||
|
||||
#include <__compare/ordering.h>
|
||||
#include <__compare/three_way_comparable.h>
|
||||
#include <__concepts/boolean_testable.h>
|
||||
#include <__config>
|
||||
#include <__utility/declval.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// [expos.only.func]
|
||||
|
||||
// TODO MODULES restore the lamba to match the Standard.
|
||||
// See https://github.com/llvm/llvm-project/issues/57222
|
||||
//_LIBCPP_HIDE_FROM_ABI inline constexpr auto __synth_three_way =
|
||||
// []<class _Tp, class _Up>(const _Tp& __t, const _Up& __u)
|
||||
template <class _Tp, class _Up>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto __synth_three_way(const _Tp& __t, const _Up& __u)
|
||||
requires requires {
|
||||
{ __t < __u } -> __boolean_testable;
|
||||
{ __u < __t } -> __boolean_testable;
|
||||
}
|
||||
{
|
||||
if constexpr (three_way_comparable_with<_Tp, _Up>) {
|
||||
return __t <=> __u;
|
||||
} else {
|
||||
if (__t < __u)
|
||||
return weak_ordering::less;
|
||||
if (__u < __t)
|
||||
return weak_ordering::greater;
|
||||
return weak_ordering::equivalent;
|
||||
}
|
||||
}
|
||||
|
||||
template <class _Tp, class _Up = _Tp>
|
||||
using __synth_three_way_result = decltype(std::__synth_three_way(std::declval<_Tp&>(), std::declval<_Up&>()));
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_SYNTH_THREE_WAY_H
|
59
third_party/libcxx/__compare/three_way_comparable.h
vendored
Normal file
59
third_party/libcxx/__compare/three_way_comparable.h
vendored
Normal file
|
@ -0,0 +1,59 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H
|
||||
#define _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H
|
||||
|
||||
#include <__compare/common_comparison_category.h>
|
||||
#include <__compare/ordering.h>
|
||||
#include <__concepts/common_reference_with.h>
|
||||
#include <__concepts/equality_comparable.h>
|
||||
#include <__concepts/same_as.h>
|
||||
#include <__concepts/totally_ordered.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/common_reference.h>
|
||||
#include <__type_traits/make_const_lvalue_ref.h>
|
||||
|
||||
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
template<class _Tp, class _Cat>
|
||||
concept __compares_as =
|
||||
same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
|
||||
|
||||
template<class _Tp, class _Cat = partial_ordering>
|
||||
concept three_way_comparable =
|
||||
__weakly_equality_comparable_with<_Tp, _Tp> &&
|
||||
__partially_ordered_with<_Tp, _Tp> &&
|
||||
requires(__make_const_lvalue_ref<_Tp> __a, __make_const_lvalue_ref<_Tp> __b) {
|
||||
{ __a <=> __b } -> __compares_as<_Cat>;
|
||||
};
|
||||
|
||||
template<class _Tp, class _Up, class _Cat = partial_ordering>
|
||||
concept three_way_comparable_with =
|
||||
three_way_comparable<_Tp, _Cat> &&
|
||||
three_way_comparable<_Up, _Cat> &&
|
||||
common_reference_with<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>> &&
|
||||
three_way_comparable<common_reference_t<__make_const_lvalue_ref<_Tp>, __make_const_lvalue_ref<_Up>>, _Cat> &&
|
||||
__weakly_equality_comparable_with<_Tp, _Up> &&
|
||||
__partially_ordered_with<_Tp, _Up> &&
|
||||
requires(__make_const_lvalue_ref<_Tp> __t, __make_const_lvalue_ref<_Up> __u) {
|
||||
{ __t <=> __u } -> __compares_as<_Cat>;
|
||||
{ __u <=> __t } -> __compares_as<_Cat>;
|
||||
};
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_THREE_WAY_COMPARABLE_H
|
102
third_party/libcxx/__compare/weak_order.h
vendored
Normal file
102
third_party/libcxx/__compare/weak_order.h
vendored
Normal file
|
@ -0,0 +1,102 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef _LIBCPP___COMPARE_WEAK_ORDER
|
||||
#define _LIBCPP___COMPARE_WEAK_ORDER
|
||||
|
||||
#include <__compare/compare_three_way.h>
|
||||
#include <__compare/ordering.h>
|
||||
#include <__compare/strong_order.h>
|
||||
#include <__config>
|
||||
#include <__type_traits/decay.h>
|
||||
#include <__utility/forward.h>
|
||||
#include <__utility/priority_tag.h>
|
||||
#include <cmath>
|
||||
|
||||
#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
|
||||
# pragma GCC system_header
|
||||
#endif
|
||||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
// [cmp.alg]
|
||||
namespace __weak_order {
|
||||
struct __fn {
|
||||
// NOLINTBEGIN(libcpp-robust-against-adl) weak_order should use ADL, but only here
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<3>)
|
||||
noexcept(noexcept(weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return weak_ordering(weak_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
// NOLINTEND(libcpp-robust-against-adl)
|
||||
|
||||
template<class _Tp, class _Up, class _Dp = decay_t<_Tp>>
|
||||
requires is_same_v<_Dp, decay_t<_Up>> && is_floating_point_v<_Dp>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr weak_ordering
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<2>) noexcept
|
||||
{
|
||||
partial_ordering __po = (__t <=> __u);
|
||||
if (__po == partial_ordering::less) {
|
||||
return weak_ordering::less;
|
||||
} else if (__po == partial_ordering::equivalent) {
|
||||
return weak_ordering::equivalent;
|
||||
} else if (__po == partial_ordering::greater) {
|
||||
return weak_ordering::greater;
|
||||
} else {
|
||||
// Otherwise, at least one of them is a NaN.
|
||||
bool __t_is_nan = _VSTD::isnan(__t);
|
||||
bool __u_is_nan = _VSTD::isnan(__u);
|
||||
bool __t_is_negative = _VSTD::signbit(__t);
|
||||
bool __u_is_negative = _VSTD::signbit(__u);
|
||||
if (__t_is_nan && __u_is_nan) {
|
||||
return (__u_is_negative <=> __t_is_negative);
|
||||
} else if (__t_is_nan) {
|
||||
return __t_is_negative ? weak_ordering::less : weak_ordering::greater;
|
||||
} else {
|
||||
return __u_is_negative ? weak_ordering::greater : weak_ordering::less;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<1>)
|
||||
noexcept(noexcept(weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return weak_ordering(compare_three_way()(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
requires is_same_v<decay_t<_Tp>, decay_t<_Up>>
|
||||
_LIBCPP_HIDE_FROM_ABI static constexpr auto
|
||||
__go(_Tp&& __t, _Up&& __u, __priority_tag<0>)
|
||||
noexcept(noexcept(weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u)))))
|
||||
-> decltype( weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))))
|
||||
{ return weak_ordering(_VSTD::strong_order(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u))); }
|
||||
|
||||
template<class _Tp, class _Up>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Tp&& __t, _Up&& __u) const
|
||||
noexcept(noexcept(__go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>())))
|
||||
-> decltype( __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()))
|
||||
{ return __go(_VSTD::forward<_Tp>(__t), _VSTD::forward<_Up>(__u), __priority_tag<3>()); }
|
||||
};
|
||||
} // namespace __weak_order
|
||||
|
||||
inline namespace __cpo {
|
||||
inline constexpr auto weak_order = __weak_order::__fn{};
|
||||
} // namespace __cpo
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
||||
_LIBCPP_END_NAMESPACE_STD
|
||||
|
||||
#endif // _LIBCPP___COMPARE_WEAK_ORDER
|
Loading…
Add table
Add a link
Reference in a new issue