summaryrefslogtreecommitdiff
path: root/third_party/libcxx/include/c++/v1/__functional
diff options
context:
space:
mode:
authorRichard Qin <richard.qin.x@gmail.com>2026-07-11 22:48:30 +0800
committerRichard Qin <richard.qin.x@gmail.com>2026-07-11 22:48:30 +0800
commit3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee (patch)
tree4bd5a49ef60ad1e371c0984cd46838368c5ef83a /third_party/libcxx/include/c++/v1/__functional
parent48ef95c24e9ac3d11200b61af617a01b10b507d1 (diff)
downloadlume-3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee.tar.gz
lume-3ad39e9878310e5317ee73c9b353c1e2c1c5c4ee.tar.xz
lib: establish Zircon libc++ and KTL foundation
Diffstat (limited to 'third_party/libcxx/include/c++/v1/__functional')
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/binary_function.h53
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/binary_negate.h51
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/bind.h288
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/bind_back.h83
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/bind_front.h103
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/binder1st.h54
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/binder2nd.h54
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/boyer_moore_searcher.h305
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/compose.h53
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/default_searcher.h54
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/function.h813
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/hash.h464
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/identity.h65
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/invoke.h55
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/is_transparent.h42
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/mem_fn.h53
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/mem_fun_ref.h145
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/not_fn.h76
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/operations.h569
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/perfect_forward.h105
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/pointer_to_binary_function.h43
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/pointer_to_unary_function.h43
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/ranges_operations.h122
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/reference_wrapper.h192
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/unary_function.h50
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/unary_negate.h47
-rw-r--r--third_party/libcxx/include/c++/v1/__functional/weak_result_type.h214
27 files changed, 4196 insertions, 0 deletions
diff --git a/third_party/libcxx/include/c++/v1/__functional/binary_function.h b/third_party/libcxx/include/c++/v1/__functional/binary_function.h
new file mode 100644
index 0000000..531274b
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/binary_function.h
@@ -0,0 +1,53 @@
+// -*- 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___FUNCTIONAL_BINARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
+template <class _Arg1, class _Arg2, class _Result>
+struct _LIBCPP_DEPRECATED_IN_CXX11 binary_function {
+ typedef _Arg1 first_argument_type;
+ typedef _Arg2 second_argument_type;
+ typedef _Result result_type;
+};
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
+template <class _Arg1, class _Arg2, class _Result>
+struct __binary_function_keep_layout_base {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using first_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg1;
+ using second_argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg2;
+ using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
+#endif
+};
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Arg1, class _Arg2, class _Result>
+using __binary_function _LIBCPP_NODEBUG = binary_function<_Arg1, _Arg2, _Result>;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#else
+template <class _Arg1, class _Arg2, class _Result>
+using __binary_function _LIBCPP_NODEBUG = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/binary_negate.h b/third_party/libcxx/include/c++/v1/__functional/binary_negate.h
new file mode 100644
index 0000000..73acfb3
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/binary_negate.h
@@ -0,0 +1,51 @@
+// -*- 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___FUNCTIONAL_BINARY_NEGATE_H
+#define _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+template <class _Predicate>
+class _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
+ : public __binary_function<typename _Predicate::first_argument_type,
+ typename _Predicate::second_argument_type,
+ bool> {
+ _Predicate __pred_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit _LIBCPP_CONSTEXPR_SINCE_CXX14 binary_negate(const _Predicate& __pred)
+ : __pred_(__pred) {}
+
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(
+ const typename _Predicate::first_argument_type& __x, const typename _Predicate::second_argument_type& __y) const {
+ return !__pred_(__x, __y);
+ }
+};
+
+template <class _Predicate>
+_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI binary_negate<_Predicate>
+not2(const _Predicate& __pred) {
+ return binary_negate<_Predicate>(__pred);
+}
+
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINARY_NEGATE_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/bind.h b/third_party/libcxx/include/c++/v1/__functional/bind.h
new file mode 100644
index 0000000..cbe8660
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/bind.h
@@ -0,0 +1,288 @@
+// -*- 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___FUNCTIONAL_BIND_H
+#define _LIBCPP___FUNCTIONAL_BIND_H
+
+#include <__config>
+#include <__functional/weak_result_type.h>
+#include <__fwd/functional.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_reference_wrapper.h>
+#include <__type_traits/is_void.h>
+#include <tuple>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct is_bind_expression
+ : _If< _IsSame<_Tp, __remove_cvref_t<_Tp> >::value, false_type, is_bind_expression<__remove_cvref_t<_Tp> > > {};
+
+#if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr bool is_bind_expression_v = is_bind_expression<_Tp>::value;
+#endif
+
+template <class _Tp>
+struct is_placeholder
+ : _If< _IsSame<_Tp, __remove_cvref_t<_Tp> >::value,
+ integral_constant<int, 0>,
+ is_placeholder<__remove_cvref_t<_Tp> > > {};
+
+#if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+inline constexpr int is_placeholder_v = is_placeholder<_Tp>::value;
+#endif
+
+namespace placeholders {
+
+template <int _Np>
+struct __ph {};
+
+// C++17 recommends that we implement placeholders as `inline constexpr`, but allows
+// implementing them as `extern <implementation-defined>`. Libc++ implements them as
+// `extern const` in all standard modes to avoid an ABI break in C++03: making them
+// `inline constexpr` requires removing their definition in the shared library to
+// avoid ODR violations, which is an ABI break.
+//
+// In practice, since placeholders are empty, `extern const` is almost impossible
+// to distinguish from `inline constexpr` from a usage stand point.
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<1> _1;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<2> _2;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<3> _3;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<4> _4;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<5> _5;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<6> _6;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<7> _7;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<8> _8;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<9> _9;
+_LIBCPP_EXPORTED_FROM_ABI extern const __ph<10> _10;
+
+} // namespace placeholders
+
+template <int _Np>
+struct is_placeholder<placeholders::__ph<_Np> > : public integral_constant<int, _Np> {};
+
+#ifndef _LIBCPP_CXX03_LANG
+
+template <class _Tp, class _Uj>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_wrapper<_Tp> __t, _Uj&) {
+ return __t.get();
+}
+
+template <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...>
+__mu(_Ti& __ti, tuple<_Uj...>& __uj) {
+ return [&]<size_t... _Indices>(__index_sequence<_Indices...>) -> __invoke_result_t<_Ti&, _Uj...> {
+ return __ti(std::forward<_Uj>(std::get<_Indices>(__uj))...);
+ }(__index_sequence_for<_Uj...>{});
+}
+
+template <bool _IsPh, class _Ti, class _Uj>
+struct __mu_return2 {};
+
+template <class _Ti, class _Uj>
+struct __mu_return2<true, _Ti, _Uj> {
+ typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _Uj>::type type;
+};
+
+template <class _Ti, class _Uj, __enable_if_t<0 < is_placeholder<_Ti>::value, int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
+__mu(_Ti&, _Uj& __uj) {
+ const size_t __indx = is_placeholder<_Ti>::value - 1;
+ return std::forward<typename tuple_element<__indx, _Uj>::type>(std::get<__indx>(__uj));
+}
+
+template <class _Ti,
+ class _Uj,
+ __enable_if_t<!is_bind_expression<_Ti>::value && is_placeholder<_Ti>::value == 0 &&
+ !__is_reference_wrapper<_Ti>::value,
+ int> = 0>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Ti& __mu(_Ti& __ti, _Uj&) {
+ return __ti;
+}
+
+template <class _Ti, bool _IsReferenceWrapper, bool _IsBindEx, bool _IsPh, class _TupleUj>
+struct __mu_return_impl;
+
+template <bool _Invokable, class _Ti, class... _Uj>
+struct __mu_return_invokable // false
+{
+ typedef __nat type;
+};
+
+template <class _Ti, class... _Uj>
+struct __mu_return_invokable<true, _Ti, _Uj...> {
+ using type _LIBCPP_NODEBUG = __invoke_result_t<_Ti&, _Uj...>;
+};
+
+template <class _Ti, class... _Uj>
+struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
+ : public __mu_return_invokable<__is_invocable_v<_Ti&, _Uj...>, _Ti, _Uj...> {};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return_impl<_Ti, false, false, true, _TupleUj> {
+ typedef typename tuple_element<is_placeholder<_Ti>::value - 1, _TupleUj>::type&& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return_impl<_Ti, true, false, false, _TupleUj> {
+ typedef typename _Ti::type& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return_impl<_Ti, false, false, false, _TupleUj> {
+ typedef _Ti& type;
+};
+
+template <class _Ti, class _TupleUj>
+struct __mu_return
+ : public __mu_return_impl<
+ _Ti,
+ __is_reference_wrapper<_Ti>::value,
+ is_bind_expression<_Ti>::value,
+ 0 < is_placeholder<_Ti>::value && is_placeholder<_Ti>::value <= tuple_size<_TupleUj>::value,
+ _TupleUj> {};
+
+template <class _Fp, class _BoundArgs, class _TupleUj>
+struct __is_valid_bind_return {
+ static const bool value = false;
+};
+
+template <class _Fp, class... _BoundArgs, class _TupleUj>
+struct __is_valid_bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj> {
+ static const bool value = __is_invocable_v<_Fp, typename __mu_return<_BoundArgs, _TupleUj>::type...>;
+};
+
+template <class _Fp, class... _BoundArgs, class _TupleUj>
+struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj> {
+ static const bool value = __is_invocable_v<_Fp, typename __mu_return<const _BoundArgs, _TupleUj>::type...>;
+};
+
+template <class _Fp, class _BoundArgs, class _TupleUj, bool = __is_valid_bind_return<_Fp, _BoundArgs, _TupleUj>::value>
+struct __bind_return;
+
+template <class _Fp, class... _BoundArgs, class _TupleUj>
+struct __bind_return<_Fp, tuple<_BoundArgs...>, _TupleUj, true> {
+ using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<_BoundArgs, _TupleUj>::type...>;
+};
+
+template <class _Fp, class... _BoundArgs, class _TupleUj>
+struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> {
+ using type _LIBCPP_NODEBUG = __invoke_result_t<_Fp&, typename __mu_return<const _BoundArgs, _TupleUj>::type...>;
+};
+
+template <class _Fp, class _BoundArgs, size_t... _Indx, class _Args>
+inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fp, _BoundArgs, _Args>::type
+__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __index_sequence<_Indx...>, _Args&& __args) {
+ return std::__invoke(__f, std::__mu(std::get<_Indx>(__bound_args), __args)...);
+}
+
+template <class _Fp, class... _BoundArgs>
+class __bind : public __weak_result_type<__decay_t<_Fp> > {
+protected:
+ using _Fd _LIBCPP_NODEBUG = __decay_t<_Fp>;
+ typedef tuple<__decay_t<_BoundArgs>...> _Td;
+
+private:
+ _Fd __f_;
+ _Td __bound_args_;
+
+public:
+ template <
+ class _Gp,
+ class... _BA,
+ __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind(_Gp&& __f, _BA&&... __bound_args)
+ : __f_(std::forward<_Gp>(__f)), __bound_args_(std::forward<_BA>(__bound_args)...) {}
+
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
+ operator()(_Args&&... __args) {
+ return std::__apply_functor(
+ __f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
+ }
+
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+ typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
+ operator()(_Args&&... __args) const {
+ return std::__apply_functor(
+ __f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
+ }
+};
+
+template <class _Fp, class... _BoundArgs>
+struct is_bind_expression<__bind<_Fp, _BoundArgs...> > : public true_type {};
+
+template <class _Rp, class _Fp, class... _BoundArgs>
+class __bind_r : public __bind<_Fp, _BoundArgs...> {
+ typedef __bind<_Fp, _BoundArgs...> base;
+ typedef typename base::_Fd _Fd;
+ typedef typename base::_Td _Td;
+
+public:
+ typedef _Rp result_type;
+
+ template <
+ class _Gp,
+ class... _BA,
+ __enable_if_t<is_constructible<_Fd, _Gp>::value && !is_same<__libcpp_remove_reference_t<_Gp>, __bind_r>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 explicit __bind_r(_Gp&& __f, _BA&&... __bound_args)
+ : base(std::forward<_Gp>(__f), std::forward<_BA>(__bound_args)...) {}
+
+ template <
+ class... _Args,
+ __enable_if_t<is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type, result_type>::value ||
+ is_void<_Rp>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) {
+ return std::__invoke_r<_Rp>(static_cast<base&>(*this), std::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args,
+ __enable_if_t<is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
+ result_type>::value ||
+ is_void<_Rp>::value,
+ int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 result_type operator()(_Args&&... __args) const {
+ return std::__invoke_r<_Rp>(static_cast<base const&>(*this), std::forward<_Args>(__args)...);
+ }
+};
+
+template <class _Rp, class _Fp, class... _BoundArgs>
+struct is_bind_expression<__bind_r<_Rp, _Fp, _BoundArgs...> > : public true_type {};
+
+template <class _Fp, class... _BoundArgs>
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind<_Fp, _BoundArgs...>
+bind(_Fp&& __f, _BoundArgs&&... __bound_args) {
+ typedef __bind<_Fp, _BoundArgs...> type;
+ return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...);
+}
+
+template <class _Rp, class _Fp, class... _BoundArgs>
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __bind_r<_Rp, _Fp, _BoundArgs...>
+bind(_Fp&& __f, _BoundArgs&&... __bound_args) {
+ typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
+ return type(std::forward<_Fp>(__f), std::forward<_BoundArgs>(__bound_args)...);
+}
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BIND_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/bind_back.h b/third_party/libcxx/include/c++/v1/__functional/bind_back.h
new file mode 100644
index 0000000..4117714
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/bind_back.h
@@ -0,0 +1,83 @@
+// -*- 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___FUNCTIONAL_BIND_BACK_H
+#define _LIBCPP___FUNCTIONAL_BIND_BACK_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.h>
+#include <__type_traits/decay.h>
+#include <__utility/forward.h>
+#include <__utility/integer_sequence.h>
+#include <tuple>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 20
+
+template <size_t _NBound, class = make_index_sequence<_NBound>>
+struct __bind_back_op;
+
+template <size_t _NBound, size_t... _Ip>
+struct __bind_back_op<_NBound, index_sequence<_Ip...>> {
+ template <class _Fn, class _BoundArgs, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn&& __f, _BoundArgs&& __bound_args, _Args&&... __args) const
+ noexcept(noexcept(std::invoke(std::forward<_Fn>(__f),
+ std::forward<_Args>(__args)...,
+ std::get<_Ip>(std::forward<_BoundArgs>(__bound_args))...)))
+ -> decltype(std::invoke(std::forward<_Fn>(__f),
+ std::forward<_Args>(__args)...,
+ std::get<_Ip>(std::forward<_BoundArgs>(__bound_args))...)) {
+ return std::invoke(std::forward<_Fn>(__f),
+ std::forward<_Args>(__args)...,
+ std::get<_Ip>(std::forward<_BoundArgs>(__bound_args))...);
+ }
+};
+
+template <class _Fn, class _BoundArgs>
+struct __bind_back_t : __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs> {
+ using __perfect_forward<__bind_back_op<tuple_size_v<_BoundArgs>>, _Fn, _BoundArgs>::__perfect_forward;
+};
+
+template <class _Fn, class... _Args>
+ requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&
+ (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)
+_LIBCPP_HIDE_FROM_ABI constexpr auto __bind_back(_Fn&& __f, _Args&&... __args) noexcept(
+ noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(
+ std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...))))
+ -> decltype(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(
+ std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...))) {
+ return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(
+ std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...));
+}
+
+# if _LIBCPP_STD_VER >= 23
+template <class _Fn, class... _Args>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto bind_back(_Fn&& __f, _Args&&... __args) {
+ static_assert(is_constructible_v<decay_t<_Fn>, _Fn>, "bind_back requires decay_t<F> to be constructible from F");
+ static_assert(is_move_constructible_v<decay_t<_Fn>>, "bind_back requires decay_t<F> to be move constructible");
+ static_assert((is_constructible_v<decay_t<_Args>, _Args> && ...),
+ "bind_back requires all decay_t<Args> to be constructible from respective Args");
+ static_assert((is_move_constructible_v<decay_t<_Args>> && ...),
+ "bind_back requires all decay_t<Args> to be move constructible");
+ return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(
+ std::forward<_Fn>(__f), std::forward_as_tuple(std::forward<_Args>(__args)...));
+}
+# endif // _LIBCPP_STD_VER >= 23
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BIND_BACK_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/bind_front.h b/third_party/libcxx/include/c++/v1/__functional/bind_front.h
new file mode 100644
index 0000000..97f8f4c
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/bind_front.h
@@ -0,0 +1,103 @@
+// -*- 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___FUNCTIONAL_BIND_FRONT_H
+#define _LIBCPP___FUNCTIONAL_BIND_FRONT_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_pointer.h>
+#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 __bind_front_op {
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const noexcept(
+ noexcept(std::invoke(std::forward<_Args>(__args)...))) -> decltype(std::invoke(std::forward<_Args>(__args)...)) {
+ return std::invoke(std::forward<_Args>(__args)...);
+ }
+};
+
+template <class _Fn, class... _BoundArgs>
+struct __bind_front_t : __perfect_forward<__bind_front_op, _Fn, _BoundArgs...> {
+ using __perfect_forward<__bind_front_op, _Fn, _BoundArgs...>::__perfect_forward;
+};
+
+template <class _Fn, class... _Args>
+ requires is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> &&
+ (is_constructible_v<decay_t<_Args>, _Args> && ...) && (is_move_constructible_v<decay_t<_Args>> && ...)
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Fn&& __f, _Args&&... __args) {
+ return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+#if _LIBCPP_STD_VER >= 26
+
+template <auto _Fn, class _Indices, class... _BoundArgs>
+struct __nttp_bind_front_t;
+
+template <auto _Fn, size_t... _Indices, class... _BoundArgs>
+struct __nttp_bind_front_t<_Fn, index_sequence<_Indices...>, _BoundArgs...> {
+ tuple<_BoundArgs...> __bound_args_;
+
+ template <class _Self, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(this _Self&& __self, _Args&&... __args) noexcept(noexcept(std::invoke(
+ _Fn, std::get<_Indices>(std::forward<_Self>(__self).__bound_args_)..., std::forward<_Args>(__args)...)))
+ -> decltype(std::invoke(
+ _Fn, std::get<_Indices>(std::forward<_Self>(__self).__bound_args_)..., std::forward<_Args>(__args)...)) {
+ return std::invoke(
+ _Fn, std::get<_Indices>(std::forward<_Self>(__self).__bound_args_)..., std::forward<_Args>(__args)...);
+ }
+};
+
+template <auto _Fn>
+struct __nttp_bind_without_bound_args_t {
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI static constexpr auto
+ operator()(_Args&&... __args) noexcept(noexcept(std::invoke(_Fn, std::forward<_Args>(__args)...)))
+ -> decltype(std::invoke(_Fn, std::forward<_Args>(__args)...)) {
+ return std::invoke(_Fn, std::forward<_Args>(__args)...);
+ }
+};
+
+template <auto _Fn, class... _Args>
+[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr auto bind_front(_Args&&... __args) {
+ static_assert((is_constructible_v<decay_t<_Args>, _Args> && ...),
+ "bind_front requires all decay_t<Args> to be constructible from respective Args");
+ static_assert((is_move_constructible_v<decay_t<_Args>> && ...),
+ "bind_front requires all decay_t<Args> to be move constructible");
+ if constexpr (using _Ty = decltype(_Fn); is_pointer_v<_Ty> || is_member_pointer_v<_Ty>)
+ static_assert(_Fn != nullptr, "bind_front: f cannot be equal to nullptr");
+
+ if constexpr (sizeof...(_Args) == 0)
+ return __nttp_bind_without_bound_args_t<_Fn>{};
+ else
+ return __nttp_bind_front_t<_Fn, index_sequence_for<_Args...>, decay_t<_Args>...>{
+ .__bound_args_{std::forward<_Args>(__args)...}};
+}
+
+#endif // _LIBCPP_STD_VER >= 26
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BIND_FRONT_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/binder1st.h b/third_party/libcxx/include/c++/v1/__functional/binder1st.h
new file mode 100644
index 0000000..77a0322
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/binder1st.h
@@ -0,0 +1,54 @@
+// -*- 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___FUNCTIONAL_BINDER1ST_H
+#define _LIBCPP___FUNCTIONAL_BINDER1ST_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class _Operation>
+class _LIBCPP_DEPRECATED_IN_CXX11 binder1st
+ : public __unary_function<typename _Operation::second_argument_type, typename _Operation::result_type> {
+protected:
+ _Operation op;
+ typename _Operation::first_argument_type value;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI binder1st(const _Operation& __x, const typename _Operation::first_argument_type __y)
+ : op(__x), value(__y) {}
+ _LIBCPP_HIDE_FROM_ABI typename _Operation::result_type
+ operator()(typename _Operation::second_argument_type& __x) const {
+ return op(value, __x);
+ }
+ _LIBCPP_HIDE_FROM_ABI typename _Operation::result_type
+ operator()(const typename _Operation::second_argument_type& __x) const {
+ return op(value, __x);
+ }
+};
+
+template <class _Operation, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI binder1st<_Operation>
+bind1st(const _Operation& __op, const _Tp& __x) {
+ return binder1st<_Operation>(__op, __x);
+}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINDER1ST_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/binder2nd.h b/third_party/libcxx/include/c++/v1/__functional/binder2nd.h
new file mode 100644
index 0000000..8cc6441
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/binder2nd.h
@@ -0,0 +1,54 @@
+// -*- 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___FUNCTIONAL_BINDER2ND_H
+#define _LIBCPP___FUNCTIONAL_BINDER2ND_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class _Operation>
+class _LIBCPP_DEPRECATED_IN_CXX11 binder2nd
+ : public __unary_function<typename _Operation::first_argument_type, typename _Operation::result_type> {
+protected:
+ _Operation op;
+ typename _Operation::second_argument_type value;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI binder2nd(const _Operation& __x, const typename _Operation::second_argument_type __y)
+ : op(__x), value(__y) {}
+ _LIBCPP_HIDE_FROM_ABI typename _Operation::result_type
+ operator()(typename _Operation::first_argument_type& __x) const {
+ return op(__x, value);
+ }
+ _LIBCPP_HIDE_FROM_ABI typename _Operation::result_type
+ operator()(const typename _Operation::first_argument_type& __x) const {
+ return op(__x, value);
+ }
+};
+
+template <class _Operation, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI binder2nd<_Operation>
+bind2nd(const _Operation& __op, const _Tp& __x) {
+ return binder2nd<_Operation>(__op, __x);
+}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_BINDER2ND_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/boyer_moore_searcher.h b/third_party/libcxx/include/c++/v1/__functional/boyer_moore_searcher.h
new file mode 100644
index 0000000..6c51c32
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/boyer_moore_searcher.h
@@ -0,0 +1,305 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
+#define _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+#include <__algorithm/fill_n.h>
+#include <__config>
+#include <__functional/hash.h>
+#include <__functional/operations.h>
+#include <__iterator/iterator_traits.h>
+#include <__memory/shared_ptr.h>
+#include <__type_traits/make_unsigned.h>
+#include <__utility/pair.h>
+#include <array>
+#include <limits>
+#include <unordered_map>
+
+#if _LIBCPP_STD_VER >= 17
+
+_LIBCPP_PUSH_MACROS
+# include <__undef_macros>
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Key, class _Value, class _Hash, class _BinaryPredicate, bool /*useArray*/>
+class _BMSkipTable;
+
+// General case for BM data searching; use a map
+template <class _Key, class _Value, class _Hash, class _BinaryPredicate>
+class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, false> {
+private:
+ using value_type = _Value;
+ using key_type = _Key;
+
+ const value_type __default_value_;
+ unordered_map<_Key, _Value, _Hash, _BinaryPredicate> __table_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit _BMSkipTable(
+ size_t __sz, value_type __default_value, _Hash __hash, _BinaryPredicate __pred)
+ : __default_value_(__default_value), __table_(__sz, __hash, __pred) {}
+
+ _LIBCPP_HIDE_FROM_ABI void insert(const key_type& __key, value_type __val) { __table_[__key] = __val; }
+
+ _LIBCPP_HIDE_FROM_ABI value_type operator[](const key_type& __key) const {
+ auto __it = __table_.find(__key);
+ return __it == __table_.end() ? __default_value_ : __it->second;
+ }
+};
+
+// Special case small numeric values; use an array
+template <class _Key, class _Value, class _Hash, class _BinaryPredicate>
+class _BMSkipTable<_Key, _Value, _Hash, _BinaryPredicate, true> {
+private:
+ using value_type = _Value;
+ using key_type = _Key;
+
+ using unsigned_key_type = make_unsigned_t<key_type>;
+ std::array<value_type, 256> __table_;
+ static_assert(numeric_limits<unsigned_key_type>::max() < 256);
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit _BMSkipTable(size_t, value_type __default_value, _Hash, _BinaryPredicate) {
+ std::fill_n(__table_.data(), __table_.size(), __default_value);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void insert(key_type __key, value_type __val) {
+ __table_[static_cast<unsigned_key_type>(__key)] = __val;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI value_type operator[](key_type __key) const {
+ return __table_[static_cast<unsigned_key_type>(__key)];
+ }
+};
+
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+ class _BinaryPredicate = equal_to<>>
+class boyer_moore_searcher {
+private:
+ using difference_type = typename std::iterator_traits<_RandomAccessIterator1>::difference_type;
+ using value_type = typename std::iterator_traits<_RandomAccessIterator1>::value_type;
+ using __skip_table_type _LIBCPP_NODEBUG =
+ _BMSkipTable<value_type,
+ difference_type,
+ _Hash,
+ _BinaryPredicate,
+ is_integral_v<value_type> && sizeof(value_type) == 1 && is_same_v<_Hash, hash<value_type>> &&
+ is_same_v<_BinaryPredicate, equal_to<>>>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI boyer_moore_searcher(
+ _RandomAccessIterator1 __first,
+ _RandomAccessIterator1 __last,
+ _Hash __hash = _Hash(),
+ _BinaryPredicate __pred = _BinaryPredicate())
+ : __first_(__first),
+ __last_(__last),
+ __pred_(__pred),
+ __pattern_length_(__last - __first),
+ __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, -1, __hash, __pred_)),
+ __suffix_(std::__allocate_shared_unbounded_array<difference_type[]>(
+ allocator<difference_type>(), __pattern_length_ + 1)) {
+ difference_type __i = 0;
+ while (__first != __last) {
+ __skip_table_->insert(*__first, __i);
+ ++__first;
+ ++__i;
+ }
+ __build_suffix_table(__first_, __last_, __pred_);
+ }
+
+ template <class _RandomAccessIterator2>
+ _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
+ static_assert(is_same_v<__remove_cvref_t<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+ __remove_cvref_t<typename iterator_traits<_RandomAccessIterator2>::value_type>>,
+ "Corpus and Pattern iterators must point to the same type");
+ if (__first == __last)
+ return std::make_pair(__last, __last);
+ if (__first_ == __last_)
+ return std::make_pair(__first, __first);
+
+ if (__pattern_length_ > (__last - __first))
+ return std::make_pair(__last, __last);
+ return __search(__first, __last);
+ }
+
+private:
+ _RandomAccessIterator1 __first_;
+ _RandomAccessIterator1 __last_;
+ _BinaryPredicate __pred_;
+ difference_type __pattern_length_;
+ shared_ptr<__skip_table_type> __skip_table_;
+ shared_ptr<difference_type[]> __suffix_;
+
+ template <class _RandomAccessIterator2>
+ _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const {
+ _RandomAccessIterator2 __current = __f;
+ const _RandomAccessIterator2 __last = __l - __pattern_length_;
+ const __skip_table_type& __skip_table = *__skip_table_;
+
+ while (__current <= __last) {
+ difference_type __j = __pattern_length_;
+ while (__pred_(__first_[__j - 1], __current[__j - 1])) {
+ --__j;
+ if (__j == 0)
+ return std::make_pair(__current, __current + __pattern_length_);
+ }
+
+ difference_type __k = __skip_table[__current[__j - 1]];
+ difference_type __m = __j - __k - 1;
+ if (__k < __j && __m > __suffix_[__j])
+ __current += __m;
+ else
+ __current += __suffix_[__j];
+ }
+ return std::make_pair(__l, __l);
+ }
+
+ template <class _Iterator, class _Container>
+ _LIBCPP_HIDE_FROM_ABI void
+ __compute_bm_prefix(_Iterator __first, _Iterator __last, _BinaryPredicate __pred, _Container& __prefix) {
+ const size_t __count = __last - __first;
+
+ __prefix[0] = 0;
+ size_t __k = 0;
+
+ for (size_t __i = 1; __i != __count; ++__i) {
+ while (__k > 0 && !__pred(__first[__k], __first[__i]))
+ __k = __prefix[__k - 1];
+
+ if (__pred(__first[__k], __first[__i]))
+ ++__k;
+ __prefix[__i] = __k;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void
+ __build_suffix_table(_RandomAccessIterator1 __first, _RandomAccessIterator1 __last, _BinaryPredicate __pred) {
+ const size_t __count = __last - __first;
+
+ if (__count == 0)
+ return;
+
+ auto __scratch = std::make_unique<difference_type[]>(__count);
+
+ __compute_bm_prefix(__first, __last, __pred, __scratch);
+ for (size_t __i = 0; __i <= __count; ++__i)
+ __suffix_[__i] = __count - __scratch[__count - 1];
+
+ using _ReverseIter = reverse_iterator<_RandomAccessIterator1>;
+ __compute_bm_prefix(_ReverseIter(__last), _ReverseIter(__first), __pred, __scratch);
+
+ for (size_t __i = 0; __i != __count; ++__i) {
+ const size_t __j = __count - __scratch[__i];
+ const difference_type __k = __i - __scratch[__i] + 1;
+
+ if (__suffix_[__j] > __k)
+ __suffix_[__j] = __k;
+ }
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_searcher);
+
+template <class _RandomAccessIterator1,
+ class _Hash = hash<typename iterator_traits<_RandomAccessIterator1>::value_type>,
+ class _BinaryPredicate = equal_to<>>
+class boyer_moore_horspool_searcher {
+private:
+ using difference_type = typename iterator_traits<_RandomAccessIterator1>::difference_type;
+ using value_type = typename iterator_traits<_RandomAccessIterator1>::value_type;
+ using __skip_table_type _LIBCPP_NODEBUG =
+ _BMSkipTable<value_type,
+ difference_type,
+ _Hash,
+ _BinaryPredicate,
+ is_integral_v<value_type> && sizeof(value_type) == 1 && is_same_v<_Hash, hash<value_type>> &&
+ is_same_v<_BinaryPredicate, equal_to<>>>;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI boyer_moore_horspool_searcher(
+ _RandomAccessIterator1 __first,
+ _RandomAccessIterator1 __last,
+ _Hash __hash = _Hash(),
+ _BinaryPredicate __pred = _BinaryPredicate())
+ : __first_(__first),
+ __last_(__last),
+ __pred_(__pred),
+ __pattern_length_(__last - __first),
+ __skip_table_(std::make_shared<__skip_table_type>(__pattern_length_, __pattern_length_, __hash, __pred_)) {
+ if (__first == __last)
+ return;
+ --__last;
+ difference_type __i = 0;
+ while (__first != __last) {
+ __skip_table_->insert(*__first, __pattern_length_ - 1 - __i);
+ ++__first;
+ ++__i;
+ }
+ }
+
+ template <class _RandomAccessIterator2>
+ _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ operator()(_RandomAccessIterator2 __first, _RandomAccessIterator2 __last) const {
+ static_assert(is_same_v<__remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator1>::value_type>,
+ __remove_cvref_t<typename std::iterator_traits<_RandomAccessIterator2>::value_type>>,
+ "Corpus and Pattern iterators must point to the same type");
+ if (__first == __last)
+ return std::make_pair(__last, __last);
+ if (__first_ == __last_)
+ return std::make_pair(__first, __first);
+
+ if (__pattern_length_ > __last - __first)
+ return std::make_pair(__last, __last);
+
+ return __search(__first, __last);
+ }
+
+private:
+ _RandomAccessIterator1 __first_;
+ _RandomAccessIterator1 __last_;
+ _BinaryPredicate __pred_;
+ difference_type __pattern_length_;
+ shared_ptr<__skip_table_type> __skip_table_;
+
+ template <class _RandomAccessIterator2>
+ _LIBCPP_HIDE_FROM_ABI pair<_RandomAccessIterator2, _RandomAccessIterator2>
+ __search(_RandomAccessIterator2 __f, _RandomAccessIterator2 __l) const {
+ _RandomAccessIterator2 __current = __f;
+ const _RandomAccessIterator2 __last = __l - __pattern_length_;
+ const __skip_table_type& __skip_table = *__skip_table_;
+
+ while (__current <= __last) {
+ difference_type __j = __pattern_length_;
+ while (__pred_(__first_[__j - 1], __current[__j - 1])) {
+ --__j;
+ if (__j == 0)
+ return std::make_pair(__current, __current + __pattern_length_);
+ }
+ __current += __skip_table[__current[__pattern_length_ - 1]];
+ }
+ return std::make_pair(__l, __l);
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(boyer_moore_horspool_searcher);
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP_STD_VER >= 17
+
+#endif // _LIBCPP___FUNCTIONAL_BOYER_MOORE_SEARCHER_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/compose.h b/third_party/libcxx/include/c++/v1/__functional/compose.h
new file mode 100644
index 0000000..4b86dd3
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/compose.h
@@ -0,0 +1,53 @@
+// -*- 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___FUNCTIONAL_COMPOSE_H
+#define _LIBCPP___FUNCTIONAL_COMPOSE_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.h>
+#include <__type_traits/decay.h>
+#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 __compose_op {
+ template <class _Fn1, class _Fn2, class... _Args>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Fn1&& __f1, _Fn2&& __f2, _Args&&... __args) const noexcept(noexcept(
+ std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))))
+ -> decltype(std::invoke(std::forward<_Fn1>(__f1),
+ std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...))) {
+ return std::invoke(std::forward<_Fn1>(__f1), std::invoke(std::forward<_Fn2>(__f2), std::forward<_Args>(__args)...));
+ }
+};
+
+template <class _Fn1, class _Fn2>
+struct __compose_t : __perfect_forward<__compose_op, _Fn1, _Fn2> {
+ using __perfect_forward<__compose_op, _Fn1, _Fn2>::__perfect_forward;
+};
+
+template <class _Fn1, class _Fn2>
+_LIBCPP_HIDE_FROM_ABI constexpr auto __compose(_Fn1&& __f1, _Fn2&& __f2) noexcept(
+ noexcept(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))))
+ -> decltype(__compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2))) {
+ return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(std::forward<_Fn1>(__f1), std::forward<_Fn2>(__f2));
+}
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_COMPOSE_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/default_searcher.h b/third_party/libcxx/include/c++/v1/__functional/default_searcher.h
new file mode 100644
index 0000000..afbf07e
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/default_searcher.h
@@ -0,0 +1,54 @@
+// -*- 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___FUNCTIONAL_DEFAULT_SEARCHER_H
+#define _LIBCPP___FUNCTIONAL_DEFAULT_SEARCHER_H
+
+#include <__algorithm/search.h>
+#include <__config>
+#include <__functional/identity.h>
+#include <__functional/operations.h>
+#include <__iterator/iterator_traits.h>
+#include <__utility/pair.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 17
+
+// default searcher
+template <class _ForwardIterator, class _BinaryPredicate = equal_to<>>
+class default_searcher {
+public:
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
+ default_searcher(_ForwardIterator __f, _ForwardIterator __l, _BinaryPredicate __p = _BinaryPredicate())
+ : __first_(__f), __last_(__l), __pred_(__p) {}
+
+ template <typename _ForwardIterator2>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair<_ForwardIterator2, _ForwardIterator2>
+ operator()(_ForwardIterator2 __f, _ForwardIterator2 __l) const {
+ auto __proj = __identity();
+ return std::__search_impl(__f, __l, __first_, __last_, __pred_, __proj, __proj);
+ }
+
+private:
+ _ForwardIterator __first_;
+ _ForwardIterator __last_;
+ _BinaryPredicate __pred_;
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(default_searcher);
+
+#endif // _LIBCPP_STD_VER >= 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_DEFAULT_SEARCHER_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/function.h b/third_party/libcxx/include/c++/v1/__functional/function.h
new file mode 100644
index 0000000..d3a978a
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/function.h
@@ -0,0 +1,813 @@
+// -*- 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___FUNCTIONAL_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_FUNCTION_H
+
+#include <__assert>
+#include <__config>
+#include <__cstddef/nullptr_t.h>
+#include <__exception/exception.h>
+#include <__functional/binary_function.h>
+#include <__functional/unary_function.h>
+#include <__memory/addressof.h>
+#include <__type_traits/aligned_storage.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_scalar.h>
+#include <__type_traits/is_trivially_constructible.h>
+#include <__type_traits/is_trivially_destructible.h>
+#include <__type_traits/strip_signature.h>
+#include <__utility/forward.h>
+#include <__utility/move.h>
+#include <__utility/swap.h>
+#include <tuple>
+#include <typeinfo>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_PUSH_MACROS
+#include <__undef_macros>
+
+#ifndef _LIBCPP_CXX03_LANG
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// bad_function_call
+
+_LIBCPP_DIAGNOSTIC_PUSH
+# if !_LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION
+_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wweak-vtables")
+# endif
+class _LIBCPP_EXPORTED_FROM_ABI bad_function_call : public exception {
+public:
+ _LIBCPP_HIDE_FROM_ABI bad_function_call() _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_function_call(const bad_function_call&) _NOEXCEPT = default;
+ _LIBCPP_HIDE_FROM_ABI bad_function_call& operator=(const bad_function_call&) _NOEXCEPT = default;
+// Note that when a key function is not used, every translation unit that uses
+// bad_function_call will end up containing a weak definition of the vtable and
+// typeinfo.
+# if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_KEY_FUNCTION
+ ~bad_function_call() _NOEXCEPT override;
+# else
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL ~bad_function_call() _NOEXCEPT override {}
+# endif
+
+# if _LIBCPP_AVAILABILITY_HAS_BAD_FUNCTION_CALL_GOOD_WHAT_MESSAGE
+ const char* what() const _NOEXCEPT override;
+# endif
+};
+_LIBCPP_DIAGNOSTIC_POP
+
+[[__noreturn__]] inline _LIBCPP_HIDE_FROM_ABI void __throw_bad_function_call() {
+# if _LIBCPP_HAS_EXCEPTIONS
+ throw bad_function_call();
+# else
+ _LIBCPP_VERBOSE_ABORT("bad_function_call was thrown in -fno-exceptions mode");
+# endif
+}
+
+template <class _Fp>
+class function; // undefined
+
+namespace __function {
+
+template <class _Rp>
+struct __maybe_derive_from_unary_function {};
+
+template <class _Rp, class _A1>
+struct __maybe_derive_from_unary_function<_Rp(_A1)> : public __unary_function<_A1, _Rp> {};
+
+template <class _Rp>
+struct __maybe_derive_from_binary_function {};
+
+template <class _Rp, class _A1, class _A2>
+struct __maybe_derive_from_binary_function<_Rp(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {};
+
+template <class _Fp>
+_LIBCPP_HIDE_FROM_ABI bool __is_null(_Fp const&) {
+ return false;
+}
+
+template <class _Fp>
+_LIBCPP_HIDE_FROM_ABI bool __is_null(_Fp* __ptr) {
+ return !__ptr;
+}
+
+template <class _Ret, class _Class>
+_LIBCPP_HIDE_FROM_ABI bool __is_null(_Ret _Class::* __ptr) {
+ return !__ptr;
+}
+
+template <class _Fp>
+_LIBCPP_HIDE_FROM_ABI bool __is_null(function<_Fp> const& __f) {
+ return !__f;
+}
+
+# if __has_extension(blocks)
+template <class _Rp, class... _Args>
+_LIBCPP_HIDE_FROM_ABI bool __is_null(_Rp (^__p)(_Args...)) {
+ return !__p;
+}
+# endif
+
+} // namespace __function
+
+namespace __function {
+
+// __base provides an abstract interface for copyable functors.
+
+template <class _Fp>
+class __base;
+
+template <class _Rp, class... _ArgTypes>
+class __base<_Rp(_ArgTypes...)> {
+public:
+ __base(const __base&) = delete;
+ __base& operator=(const __base&) = delete;
+
+ _LIBCPP_HIDE_FROM_ABI __base() {}
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual ~__base() {}
+ virtual __base* __clone() const = 0;
+ virtual void __clone(__base*) const = 0;
+ virtual void destroy() _NOEXCEPT = 0;
+ virtual void destroy_deallocate() _NOEXCEPT = 0;
+ virtual _Rp operator()(_ArgTypes&&...) = 0;
+# if _LIBCPP_HAS_RTTI
+ virtual const void* target(const type_info&) const _NOEXCEPT = 0;
+ virtual const std::type_info& target_type() const _NOEXCEPT = 0;
+# endif // _LIBCPP_HAS_RTTI
+};
+
+// __func implements __base for a given functor type.
+
+template <class _FD, class _FB>
+class __func;
+
+template <class _Fp, class _Rp, class... _ArgTypes>
+class __func<_Fp, _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
+ _Fp __func_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __func(_Fp&& __f) : __func_(std::move(__f)) {}
+ _LIBCPP_HIDE_FROM_ABI explicit __func(const _Fp& __f) : __func_(__f) {}
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL __base<_Rp(_ArgTypes...)>* __clone() const override { return new __func(__func_); }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL void __clone(__base<_Rp(_ArgTypes...)>* __p) const override {
+ ::new ((void*)__p) __func(__func_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL void destroy() _NOEXCEPT override { __func_.~_Fp(); }
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL void destroy_deallocate() _NOEXCEPT override { delete this; }
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL _Rp operator()(_ArgTypes&&... __arg) override {
+ return std::__invoke_r<_Rp>(__func_, std::forward<_ArgTypes>(__arg)...);
+ }
+# if _LIBCPP_HAS_RTTI
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const void* target(const type_info& __ti) const _NOEXCEPT override {
+ if (__ti == typeid(_Fp))
+ return std::addressof(__func_);
+ return nullptr;
+ }
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL const std::type_info& target_type() const _NOEXCEPT override { return typeid(_Fp); }
+# endif // _LIBCPP_HAS_RTTI
+};
+
+// __value_func creates a value-type from a __func.
+
+template <class _Fp>
+class __value_func;
+
+template <class _Rp, class... _ArgTypes>
+class __value_func<_Rp(_ArgTypes...)> {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ typename aligned_storage<3 * sizeof(void*)>::type __buf_;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+
+ typedef __base<_Rp(_ArgTypes...)> __func;
+ __func* __f_;
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_NO_CFI static __func* __as_base(void* __p) { return reinterpret_cast<__func*>(__p); }
+
+public:
+ _LIBCPP_HIDE_FROM_ABI __value_func() _NOEXCEPT : __f_(nullptr) {}
+
+ template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __value_func>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI explicit __value_func(_Fp&& __f) : __f_(nullptr) {
+ typedef __function::__func<_Fp, _Rp(_ArgTypes...)> _Fun;
+
+ if (__function::__is_null(__f))
+ return;
+
+ if (sizeof(_Fun) <= sizeof(__buf_) && is_nothrow_copy_constructible<_Fp>::value) {
+ __f_ = ::new (std::addressof(__buf_)) _Fun(std::move(__f));
+ } else {
+ __f_ = new _Fun(std::move(__f));
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __value_func(const __value_func& __f) {
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if ((void*)__f.__f_ == &__f.__buf_) {
+ __f_ = __as_base(&__buf_);
+ __f.__f_->__clone(__f_);
+ } else
+ __f_ = __f.__f_->__clone();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __value_func(__value_func&& __f) _NOEXCEPT {
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if ((void*)__f.__f_ == &__f.__buf_) {
+ __f_ = __as_base(&__buf_);
+ __f.__f_->__clone(__f_);
+ } else {
+ __f_ = __f.__f_;
+ __f.__f_ = nullptr;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI ~__value_func() {
+ if ((void*)__f_ == &__buf_)
+ __f_->destroy();
+ else if (__f_)
+ __f_->destroy_deallocate();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __value_func& operator=(__value_func&& __f) {
+ *this = nullptr;
+ if (__f.__f_ == nullptr)
+ __f_ = nullptr;
+ else if ((void*)__f.__f_ == &__f.__buf_) {
+ __f_ = __as_base(&__buf_);
+ __f.__f_->__clone(__f_);
+ } else {
+ __f_ = __f.__f_;
+ __f.__f_ = nullptr;
+ }
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __value_func& operator=(nullptr_t) {
+ __func* __f = __f_;
+ __f_ = nullptr;
+ if ((void*)__f == &__buf_)
+ __f->destroy();
+ else if (__f)
+ __f->destroy_deallocate();
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {
+ if (__f_ == nullptr)
+ std::__throw_bad_function_call();
+ return (*__f_)(std::forward<_ArgTypes>(__args)...);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void swap(__value_func& __f) _NOEXCEPT {
+ if (std::addressof(__f) == this)
+ return;
+ if ((void*)__f_ == &__buf_ && (void*)__f.__f_ == &__f.__buf_) {
+ _LIBCPP_SUPPRESS_DEPRECATED_PUSH
+ typename aligned_storage<sizeof(__buf_)>::type __tempbuf;
+ _LIBCPP_SUPPRESS_DEPRECATED_POP
+ __func* __t = __as_base(&__tempbuf);
+ __f_->__clone(__t);
+ __f_->destroy();
+ __f_ = nullptr;
+ __f.__f_->__clone(__as_base(&__buf_));
+ __f.__f_->destroy();
+ __f.__f_ = nullptr;
+ __f_ = __as_base(&__buf_);
+ __t->__clone(__as_base(&__f.__buf_));
+ __t->destroy();
+ __f.__f_ = __as_base(&__f.__buf_);
+ } else if ((void*)__f_ == &__buf_) {
+ __f_->__clone(__as_base(&__f.__buf_));
+ __f_->destroy();
+ __f_ = __f.__f_;
+ __f.__f_ = __as_base(&__f.__buf_);
+ } else if ((void*)__f.__f_ == &__f.__buf_) {
+ __f.__f_->__clone(__as_base(&__buf_));
+ __f.__f_->destroy();
+ __f.__f_ = __f_;
+ __f_ = __as_base(&__buf_);
+ } else
+ std::swap(__f_, __f.__f_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return __f_ != nullptr; }
+
+# if _LIBCPP_HAS_RTTI
+ _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT {
+ if (__f_ == nullptr)
+ return typeid(void);
+ return __f_->target_type();
+ }
+
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT {
+ if (__f_ == nullptr)
+ return nullptr;
+ return (const _Tp*)__f_->target(typeid(_Tp));
+ }
+# endif // _LIBCPP_HAS_RTTI
+};
+
+// Storage for a functor object, to be used with __policy to manage copy and
+// destruction.
+union __policy_storage {
+ mutable char __small[sizeof(void*) * 2];
+ void* __large;
+};
+
+// True if _Fun can safely be held in __policy_storage.__small.
+template <typename _Fun>
+struct __use_small_storage
+ : public integral_constant<
+ bool,
+ sizeof(_Fun) <= sizeof(__policy_storage)&& _LIBCPP_ALIGNOF(_Fun) <= _LIBCPP_ALIGNOF(__policy_storage) &&
+ is_trivially_copy_constructible<_Fun>::value && is_trivially_destructible<_Fun>::value> {};
+
+// Policy contains information about how to copy, destroy, and move the
+// underlying functor. You can think of it as a vtable of sorts.
+struct __policy {
+ // Used to copy or destroy __large values. null for trivial objects.
+ void* (*const __clone)(const void*);
+ void (*const __destroy)(void*);
+
+ // True if this is the null policy (no value).
+ const bool __is_null;
+
+ // The target type. May be null if RTTI is disabled.
+ const std::type_info* const __type_info;
+
+ // Returns a pointer to a static policy object suitable for the functor
+ // type.
+ template <typename _Fun>
+ _LIBCPP_HIDE_FROM_ABI static const __policy* __create() {
+ if constexpr (__use_small_storage<_Fun>::value) {
+ static constexpr __policy __policy = {
+ nullptr,
+ nullptr,
+ false,
+# if _LIBCPP_HAS_RTTI
+ &typeid(_Fun)
+# else
+ nullptr
+# endif
+ };
+ return &__policy;
+ } else {
+ static constexpr __policy __policy = {
+ std::addressof(__large_clone<_Fun>),
+ std::addressof(__large_destroy<_Fun>),
+ false,
+# if _LIBCPP_HAS_RTTI
+ &typeid(_Fun)
+# else
+ nullptr
+# endif
+ };
+ return &__policy;
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static const __policy* __create_empty() {
+ static constexpr __policy __policy = {
+ nullptr,
+ nullptr,
+ true,
+# if _LIBCPP_HAS_RTTI
+ &typeid(void)
+# else
+ nullptr
+# endif
+ };
+ return &__policy;
+ }
+
+private:
+ template <typename _Fun>
+ _LIBCPP_HIDE_FROM_ABI static void* __large_clone(const void* __s) {
+ const _Fun* __f = static_cast<const _Fun*>(__s);
+ return new _Fun(*__f);
+ }
+
+ template <typename _Fun>
+ _LIBCPP_HIDE_FROM_ABI static void __large_destroy(void* __s) {
+ delete static_cast<_Fun*>(__s);
+ }
+};
+
+// Used to choose between perfect forwarding or pass-by-value. Pass-by-value is
+// faster for types that can be passed in registers.
+template <typename _Tp>
+using __fast_forward _LIBCPP_NODEBUG = __conditional_t<is_scalar<_Tp>::value, _Tp, _Tp&&>;
+
+// __policy_func uses a __policy to create a type-erased, copyable functor.
+
+template <class _Fp>
+class __policy_func;
+
+template <class _Rp, class... _ArgTypes>
+class __policy_func<_Rp(_ArgTypes...)> {
+ // Inline storage for small objects.
+ __policy_storage __buf_;
+
+ using _ErasedFunc _LIBCPP_NODEBUG = _Rp(const __policy_storage*, __fast_forward<_ArgTypes>...);
+
+ _ErasedFunc* __func_;
+
+ // The policy that describes how to move / copy / destroy __buf_. Never
+ // null, even if the function is empty.
+ const __policy* __policy_;
+
+ _LIBCPP_HIDE_FROM_ABI static _Rp __empty_func(const __policy_storage*, __fast_forward<_ArgTypes>...) {
+ std::__throw_bad_function_call();
+ }
+
+ template <class _Fun>
+ _LIBCPP_HIDE_FROM_ABI static _Rp __call_func(const __policy_storage* __buf, __fast_forward<_ArgTypes>... __args) {
+ _Fun* __func = reinterpret_cast<_Fun*>(__use_small_storage<_Fun>::value ? &__buf->__small : __buf->__large);
+
+ return std::__invoke_r<_Rp>(*__func, std::forward<_ArgTypes>(__args)...);
+ }
+
+public:
+ _LIBCPP_HIDE_FROM_ABI __policy_func() : __func_(__empty_func), __policy_(__policy::__create_empty()) {}
+
+ template <class _Fp, __enable_if_t<!is_same<__decay_t<_Fp>, __policy_func>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI explicit __policy_func(_Fp&& __f) : __policy_(__policy::__create_empty()) {
+ if (__function::__is_null(__f))
+ return;
+
+ __func_ = __call_func<_Fp>;
+ __policy_ = __policy::__create<_Fp>();
+ if (__use_small_storage<_Fp>()) {
+ ::new ((void*)&__buf_.__small) _Fp(std::move(__f));
+ } else {
+ __buf_.__large = ::new _Fp(std::move(__f));
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __policy_func(const __policy_func& __f)
+ : __buf_(__f.__buf_), __func_(__f.__func_), __policy_(__f.__policy_) {
+ if (__policy_->__clone)
+ __buf_.__large = __policy_->__clone(__f.__buf_.__large);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __policy_func(__policy_func&& __f)
+ : __buf_(__f.__buf_), __func_(__f.__func_), __policy_(__f.__policy_) {
+ if (__policy_->__destroy) {
+ __f.__policy_ = __policy::__create_empty();
+ __f.__func_ = {};
+ }
+ }
+
+ _LIBCPP_HIDE_FROM_ABI ~__policy_func() {
+ if (__policy_->__destroy)
+ __policy_->__destroy(__buf_.__large);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(__policy_func&& __f) {
+ *this = nullptr;
+ __buf_ = __f.__buf_;
+ __func_ = __f.__func_;
+ __policy_ = __f.__policy_;
+ __f.__policy_ = __policy::__create_empty();
+ __f.__func_ = {};
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI __policy_func& operator=(nullptr_t) {
+ const __policy* __p = __policy_;
+ __policy_ = __policy::__create_empty();
+ __func_ = {};
+ if (__p->__destroy)
+ __p->__destroy(__buf_.__large);
+ return *this;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes&&... __args) const {
+ return __func_(std::addressof(__buf_), std::forward<_ArgTypes>(__args)...);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI void swap(__policy_func& __f) {
+ std::swap(__func_, __f.__func_);
+ std::swap(__policy_, __f.__policy_);
+ std::swap(__buf_, __f.__buf_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return !__policy_->__is_null; }
+
+# if _LIBCPP_HAS_RTTI
+ _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT { return *__policy_->__type_info; }
+
+ template <typename _Tp>
+ _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT {
+ if (__policy_->__is_null || typeid(_Tp) != *__policy_->__type_info)
+ return nullptr;
+ if (__policy_->__clone) // Out of line storage.
+ return reinterpret_cast<const _Tp*>(__buf_.__large);
+ else
+ return reinterpret_cast<const _Tp*>(&__buf_.__small);
+ }
+# endif // _LIBCPP_HAS_RTTI
+};
+
+# if _LIBCPP_HAS_BLOCKS_RUNTIME
+
+extern "C" void* _Block_copy(const void*);
+extern "C" void _Block_release(const void*);
+
+template <class _Rp1, class... _ArgTypes1, class _Rp, class... _ArgTypes>
+class __func<_Rp1 (^)(_ArgTypes1...), _Rp(_ArgTypes...)> : public __base<_Rp(_ArgTypes...)> {
+ typedef _Rp1 (^__block_type)(_ArgTypes1...);
+ __block_type __f_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit __func(__block_type const& __f)
+# if __has_feature(objc_arc)
+ : __f_(__f)
+# else
+ : __f_(reinterpret_cast<__block_type>(__f ? __function::_Block_copy(__f) : nullptr))
+# endif
+ {
+ }
+
+ // [TODO] add && to save on a retain
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual __base<_Rp(_ArgTypes...)>* __clone() const {
+ _LIBCPP_ASSERT_INTERNAL(
+ false,
+ "Block pointers are just pointers, so they should always fit into "
+ "std::function's small buffer optimization. This function should "
+ "never be invoked.");
+ return nullptr;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void __clone(__base<_Rp(_ArgTypes...)>* __p) const {
+ ::new ((void*)__p) __func(__f_);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy() _NOEXCEPT {
+# if !__has_feature(objc_arc)
+ if (__f_)
+ __function::_Block_release(__f_);
+# endif
+ __f_ = 0;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual void destroy_deallocate() _NOEXCEPT {
+ _LIBCPP_ASSERT_INTERNAL(
+ false,
+ "Block pointers are just pointers, so they should always fit into "
+ "std::function's small buffer optimization. This function should "
+ "never be invoked.");
+ }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual _Rp operator()(_ArgTypes&&... __arg) {
+ return std::__invoke(__f_, std::forward<_ArgTypes>(__arg)...);
+ }
+
+# if _LIBCPP_HAS_RTTI
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const void* target(type_info const& __ti) const _NOEXCEPT {
+ if (__ti == typeid(__func::__block_type))
+ return &__f_;
+ return (const void*)nullptr;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI_VIRTUAL virtual const std::type_info& target_type() const _NOEXCEPT {
+ return typeid(__func::__block_type);
+ }
+# endif // _LIBCPP_HAS_RTTI
+};
+
+# endif // _LIBCPP_HAS_BLOCKS_RUNTIME
+
+} // namespace __function
+
+template <class _Rp, class... _ArgTypes>
+class function<_Rp(_ArgTypes...)>
+ : public __function::__maybe_derive_from_unary_function<_Rp(_ArgTypes...)>,
+ public __function::__maybe_derive_from_binary_function<_Rp(_ArgTypes...)> {
+# ifndef _LIBCPP_ABI_OPTIMIZED_FUNCTION
+ typedef __function::__value_func<_Rp(_ArgTypes...)> __func;
+# else
+ typedef __function::__policy_func<_Rp(_ArgTypes...)> __func;
+# endif
+
+ __func __f_;
+
+ template <class _Fp>
+ using _EnableIfLValueCallable _LIBCPP_NODEBUG = __enable_if_t<
+ _And<_IsNotSame<__remove_cvref_t<_Fp>, function>, __is_invocable_r<_Rp, _Fp&, _ArgTypes...>>::value>;
+
+public:
+ typedef _Rp result_type;
+
+ // construct/copy/destroy:
+ _LIBCPP_HIDE_FROM_ABI function() _NOEXCEPT {}
+ _LIBCPP_HIDE_FROM_ABI function(nullptr_t) _NOEXCEPT {}
+ _LIBCPP_HIDE_FROM_ABI function(const function&);
+ _LIBCPP_HIDE_FROM_ABI function(function&&) _NOEXCEPT;
+ template <class _Fp, class = _EnableIfLValueCallable<_Fp>>
+ _LIBCPP_HIDE_FROM_ABI function(_Fp);
+
+# if _LIBCPP_STD_VER <= 14
+ template <class _Alloc>
+ _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&) _NOEXCEPT {}
+ template <class _Alloc>
+ _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&, nullptr_t) _NOEXCEPT {}
+ template <class _Alloc>
+ _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&, const function&);
+ template <class _Alloc>
+ _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc&, function&&);
+ template <class _Fp, class _Alloc, class = _EnableIfLValueCallable<_Fp>>
+ _LIBCPP_HIDE_FROM_ABI function(allocator_arg_t, const _Alloc& __a, _Fp __f);
+# endif
+
+ _LIBCPP_HIDE_FROM_ABI function& operator=(const function&);
+ _LIBCPP_HIDE_FROM_ABI function& operator=(function&&) _NOEXCEPT;
+ _LIBCPP_HIDE_FROM_ABI function& operator=(nullptr_t) _NOEXCEPT;
+ template <class _Fp, class = _EnableIfLValueCallable<__decay_t<_Fp>>>
+ _LIBCPP_HIDE_FROM_ABI function& operator=(_Fp&&);
+
+ _LIBCPP_HIDE_FROM_ABI ~function();
+
+ // function modifiers:
+ _LIBCPP_HIDE_FROM_ABI void swap(function&) _NOEXCEPT;
+
+# if _LIBCPP_STD_VER <= 14
+ template <class _Fp, class _Alloc>
+ _LIBCPP_HIDE_FROM_ABI void assign(_Fp&& __f, const _Alloc& __a) {
+ function(allocator_arg, __a, std::forward<_Fp>(__f)).swap(*this);
+ }
+# endif
+
+ // function capacity:
+ _LIBCPP_HIDE_FROM_ABI explicit operator bool() const _NOEXCEPT { return static_cast<bool>(__f_); }
+
+ // deleted overloads close possible hole in the type system
+ template <class _R2, class... _ArgTypes2>
+ bool operator==(const function<_R2(_ArgTypes2...)>&) const = delete;
+# if _LIBCPP_STD_VER <= 17
+ template <class _R2, class... _ArgTypes2>
+ bool operator!=(const function<_R2(_ArgTypes2...)>&) const = delete;
+# endif
+
+public:
+ // function invocation:
+ _LIBCPP_HIDE_FROM_ABI _Rp operator()(_ArgTypes...) const;
+
+# if _LIBCPP_HAS_RTTI
+ // function target access:
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const std::type_info& target_type() const _NOEXCEPT;
+ template <typename _Tp>
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _Tp* target() _NOEXCEPT;
+ template <typename _Tp>
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI const _Tp* target() const _NOEXCEPT;
+# endif // _LIBCPP_HAS_RTTI
+};
+
+# if _LIBCPP_STD_VER >= 17
+template <class _Rp, class... _Ap>
+function(_Rp (*)(_Ap...)) -> function<_Rp(_Ap...)>;
+
+template <class _Fp, class _Stripped = __strip_signature_t<decltype(&_Fp::operator())>>
+function(_Fp) -> function<_Stripped>;
+# endif // _LIBCPP_STD_VER >= 17
+
+template <class _Rp, class... _ArgTypes>
+function<_Rp(_ArgTypes...)>::function(const function& __f) : __f_(__f.__f_) {}
+
+# if _LIBCPP_STD_VER <= 14
+template <class _Rp, class... _ArgTypes>
+template <class _Alloc>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, const function& __f) : __f_(__f.__f_) {}
+# endif
+
+template <class _Rp, class... _ArgTypes>
+function<_Rp(_ArgTypes...)>::function(function&& __f) _NOEXCEPT : __f_(std::move(__f.__f_)) {}
+
+# if _LIBCPP_STD_VER <= 14
+template <class _Rp, class... _ArgTypes>
+template <class _Alloc>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, function&& __f) : __f_(std::move(__f.__f_)) {}
+# endif
+
+template <class _Rp, class... _ArgTypes>
+template <class _Fp, class>
+function<_Rp(_ArgTypes...)>::function(_Fp __f) : __f_(std::move(__f)) {}
+
+# if _LIBCPP_STD_VER <= 14
+template <class _Rp, class... _ArgTypes>
+template <class _Fp, class _Alloc, class>
+function<_Rp(_ArgTypes...)>::function(allocator_arg_t, const _Alloc&, _Fp __f) : __f_(std::move(__f)) {}
+# endif
+
+template <class _Rp, class... _ArgTypes>
+function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(const function& __f) {
+ function(__f).swap(*this);
+ return *this;
+}
+
+template <class _Rp, class... _ArgTypes>
+function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(function&& __f) _NOEXCEPT {
+ __f_ = std::move(__f.__f_);
+ return *this;
+}
+
+template <class _Rp, class... _ArgTypes>
+function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(nullptr_t) _NOEXCEPT {
+ __f_ = nullptr;
+ return *this;
+}
+
+template <class _Rp, class... _ArgTypes>
+template <class _Fp, class>
+function<_Rp(_ArgTypes...)>& function<_Rp(_ArgTypes...)>::operator=(_Fp&& __f) {
+ function(std::forward<_Fp>(__f)).swap(*this);
+ return *this;
+}
+
+template <class _Rp, class... _ArgTypes>
+function<_Rp(_ArgTypes...)>::~function() {}
+
+template <class _Rp, class... _ArgTypes>
+void function<_Rp(_ArgTypes...)>::swap(function& __f) _NOEXCEPT {
+ __f_.swap(__f.__f_);
+}
+
+template <class _Rp, class... _ArgTypes>
+_Rp function<_Rp(_ArgTypes...)>::operator()(_ArgTypes... __arg) const {
+ return __f_(std::forward<_ArgTypes>(__arg)...);
+}
+
+# if _LIBCPP_HAS_RTTI
+
+template <class _Rp, class... _ArgTypes>
+const std::type_info& function<_Rp(_ArgTypes...)>::target_type() const _NOEXCEPT {
+ return __f_.target_type();
+}
+
+template <class _Rp, class... _ArgTypes>
+template <typename _Tp>
+_Tp* function<_Rp(_ArgTypes...)>::target() _NOEXCEPT {
+ return (_Tp*)(__f_.template target<_Tp>());
+}
+
+template <class _Rp, class... _ArgTypes>
+template <typename _Tp>
+const _Tp* function<_Rp(_ArgTypes...)>::target() const _NOEXCEPT {
+ return __f_.template target<_Tp>();
+}
+
+# endif // _LIBCPP_HAS_RTTI
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_HIDE_FROM_ABI bool operator==(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {
+ return !__f;
+}
+
+# if _LIBCPP_STD_VER <= 17
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_HIDE_FROM_ABI bool operator==(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {
+ return !__f;
+}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const function<_Rp(_ArgTypes...)>& __f, nullptr_t) _NOEXCEPT {
+ return (bool)__f;
+}
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_HIDE_FROM_ABI bool operator!=(nullptr_t, const function<_Rp(_ArgTypes...)>& __f) _NOEXCEPT {
+ return (bool)__f;
+}
+
+# endif // _LIBCPP_STD_VER <= 17
+
+template <class _Rp, class... _ArgTypes>
+inline _LIBCPP_HIDE_FROM_ABI void swap(function<_Rp(_ArgTypes...)>& __x, function<_Rp(_ArgTypes...)>& __y) _NOEXCEPT {
+ return __x.swap(__y);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP_CXX03_LANG
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FUNCTIONAL_FUNCTION_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/hash.h b/third_party/libcxx/include/c++/v1/__functional/hash.h
new file mode 100644
index 0000000..fa71819
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/hash.h
@@ -0,0 +1,464 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___FUNCTIONAL_HASH_H
+#define _LIBCPP___FUNCTIONAL_HASH_H
+
+#include <__config>
+#include <__cstddef/nullptr_t.h>
+#include <__functional/unary_function.h>
+#include <__fwd/functional.h>
+#include <__memory/addressof.h>
+#include <__type_traits/conjunction.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_enum.h>
+#include <__type_traits/is_floating_point.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/is_unqualified.h>
+#include <__type_traits/underlying_type.h>
+#include <__utility/swap.h>
+#include <cstdint>
+#include <cstring>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Size>
+inline _LIBCPP_HIDE_FROM_ABI _Size __loadword(const void* __p) {
+ _Size __r;
+ std::memcpy(std::addressof(__r), __p, sizeof(__r));
+ return __r;
+}
+
+struct _PairT {
+ size_t first;
+ size_t second;
+};
+
+// We use murmur2 when size_t is 32 bits, and cityhash64 when size_t
+// is 64 bits. This is because cityhash64 uses 64bit x 64bit
+// multiplication, which can be very slow on 32-bit systems.
+template <class _Size, size_t = sizeof(_Size) * __CHAR_BIT__>
+struct __murmur2_or_cityhash;
+
+template <class _Size>
+struct __murmur2_or_cityhash<_Size, 32> {
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _Size
+ operator()(const void* __key, _Size __len) const {
+ // murmur2
+ const _Size __m = 0x5bd1e995;
+ const _Size __r = 24;
+ _Size __h = __len;
+ const unsigned char* __data = static_cast<const unsigned char*>(__key);
+ for (; __len >= 4; __data += 4, __len -= 4) {
+ _Size __k = std::__loadword<_Size>(__data);
+ __k *= __m;
+ __k ^= __k >> __r;
+ __k *= __m;
+ __h *= __m;
+ __h ^= __k;
+ }
+ switch (__len) {
+ case 3:
+ __h ^= static_cast<_Size>(__data[2] << 16);
+ [[__fallthrough__]];
+ case 2:
+ __h ^= static_cast<_Size>(__data[1] << 8);
+ [[__fallthrough__]];
+ case 1:
+ __h ^= __data[0];
+ __h *= __m;
+ }
+ __h ^= __h >> 13;
+ __h *= __m;
+ __h ^= __h >> 15;
+ return __h;
+ }
+};
+
+template <class _Size>
+struct __murmur2_or_cityhash<_Size, 64> {
+ // cityhash64
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK _Size
+ operator()(const void* __key, _Size __len) const {
+ const char* __s = static_cast<const char*>(__key);
+ if (__len <= 32) {
+ if (__len <= 16) {
+ return __hash_len_0_to_16(__s, __len);
+ } else {
+ return __hash_len_17_to_32(__s, __len);
+ }
+ } else if (__len <= 64) {
+ return __hash_len_33_to_64(__s, __len);
+ }
+
+ // For strings over 64 bytes we hash the end first, and then as we
+ // loop we keep 56 bytes of state: v, w, x, y, and z.
+ _Size __x = std::__loadword<_Size>(__s + __len - 40);
+ _Size __y = std::__loadword<_Size>(__s + __len - 16) + std::__loadword<_Size>(__s + __len - 56);
+ _Size __z =
+ __hash_len_16(std::__loadword<_Size>(__s + __len - 48) + __len, std::__loadword<_Size>(__s + __len - 24));
+ _PairT __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
+ _PairT __w = __weak_hash_len_32_with_seeds(__s + __len - 32, __y + __k1, __x);
+ __x = __x * __k1 + std::__loadword<_Size>(__s);
+
+ // Decrease len to the nearest multiple of 64, and operate on 64-byte chunks.
+ __len = (__len - 1) & ~static_cast<_Size>(63);
+ do {
+ __x = __rotate(__x + __y + __v.first + std::__loadword<_Size>(__s + 8), 37) * __k1;
+ __y = __rotate(__y + __v.second + std::__loadword<_Size>(__s + 48), 42) * __k1;
+ __x ^= __w.second;
+ __y += __v.first + std::__loadword<_Size>(__s + 40);
+ __z = __rotate(__z + __w.first, 33) * __k1;
+ __v = __weak_hash_len_32_with_seeds(__s, __v.second * __k1, __x + __w.first);
+ __w = __weak_hash_len_32_with_seeds(__s + 32, __z + __w.second, __y + std::__loadword<_Size>(__s + 16));
+ std::swap(__z, __x);
+ __s += 64;
+ __len -= 64;
+ } while (__len != 0);
+ return __hash_len_16(__hash_len_16(__v.first, __w.first) + __shift_mix(__y) * __k1 + __z,
+ __hash_len_16(__v.second, __w.second) + __x);
+ }
+
+private:
+ // Some primes between 2^63 and 2^64.
+ static const _Size __k0 = 0xc3a5c85c97cb3127ULL;
+ static const _Size __k1 = 0xb492b66fbe98f273ULL;
+ static const _Size __k2 = 0x9ae16a3b2f90404fULL;
+ static const _Size __k3 = 0xc949d7c7509e6557ULL;
+
+ _LIBCPP_HIDE_FROM_ABI static _Size __rotate(_Size __val, int __shift) {
+ return __shift == 0 ? __val : ((__val >> __shift) | (__val << (64 - __shift)));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static _Size __rotate_by_at_least_1(_Size __val, int __shift) {
+ return (__val >> __shift) | (__val << (64 - __shift));
+ }
+
+ _LIBCPP_HIDE_FROM_ABI static _Size __shift_mix(_Size __val) { return __val ^ (__val >> 47); }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size __hash_len_16(_Size __u, _Size __v) {
+ const _Size __mul = 0x9ddfea08eb382d69ULL;
+ _Size __a = (__u ^ __v) * __mul;
+ __a ^= (__a >> 47);
+ _Size __b = (__v ^ __a) * __mul;
+ __b ^= (__b >> 47);
+ __b *= __mul;
+ return __b;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size
+ __hash_len_0_to_16(const char* __s, _Size __len) {
+ if (__len > 8) {
+ const _Size __a = std::__loadword<_Size>(__s);
+ const _Size __b = std::__loadword<_Size>(__s + __len - 8);
+ return __hash_len_16(__a, __rotate_by_at_least_1(__b + __len, __len)) ^ __b;
+ }
+ if (__len >= 4) {
+ const uint32_t __a = std::__loadword<uint32_t>(__s);
+ const uint32_t __b = std::__loadword<uint32_t>(__s + __len - 4);
+#ifdef _LIBCPP_ABI_FIX_CITYHASH_IMPLEMENTATION
+ return __hash_len_16(__len + (static_cast<_Size>(__a) << 3), __b);
+#else
+ return __hash_len_16(__len + (__a << 3), __b);
+#endif
+ }
+ if (__len > 0) {
+ const unsigned char __a = static_cast<unsigned char>(__s[0]);
+ const unsigned char __b = static_cast<unsigned char>(__s[__len >> 1]);
+ const unsigned char __c = static_cast<unsigned char>(__s[__len - 1]);
+ const uint32_t __y = static_cast<uint32_t>(__a) + (static_cast<uint32_t>(__b) << 8);
+ const uint32_t __z = __len + (static_cast<uint32_t>(__c) << 2);
+ return __shift_mix(__y * __k2 ^ __z * __k3) * __k2;
+ }
+ return __k2;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size
+ __hash_len_17_to_32(const char* __s, _Size __len) {
+ const _Size __a = std::__loadword<_Size>(__s) * __k1;
+ const _Size __b = std::__loadword<_Size>(__s + 8);
+ const _Size __c = std::__loadword<_Size>(__s + __len - 8) * __k2;
+ const _Size __d = std::__loadword<_Size>(__s + __len - 16) * __k0;
+ return __hash_len_16(
+ __rotate(__a - __b, 43) + __rotate(__c, 30) + __d, __a + __rotate(__b ^ __k3, 20) - __c + __len);
+ }
+
+ // Return a 16-byte hash for 48 bytes. Quick and dirty.
+ // Callers do best to use "random-looking" values for a and b.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _PairT
+ __weak_hash_len_32_with_seeds(_Size __w, _Size __x, _Size __y, _Size __z, _Size __a, _Size __b) {
+ __a += __w;
+ __b = __rotate(__b + __a + __z, 21);
+ const _Size __c = __a;
+ __a += __x;
+ __a += __y;
+ __b += __rotate(__a, 44);
+ _PairT __ret;
+ __ret.first = __a + __z;
+ __ret.second = __b + __c;
+ return __ret;
+ }
+
+ // Return a 16-byte hash for s[0] ... s[31], a, and b. Quick and dirty.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _PairT
+ __weak_hash_len_32_with_seeds(const char* __s, _Size __a, _Size __b) {
+ return __weak_hash_len_32_with_seeds(
+ std::__loadword<_Size>(__s),
+ std::__loadword<_Size>(__s + 8),
+ std::__loadword<_Size>(__s + 16),
+ std::__loadword<_Size>(__s + 24),
+ __a,
+ __b);
+ }
+
+ // Return an 8-byte hash for 33 to 64 bytes.
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_DISABLE_UBSAN_UNSIGNED_INTEGER_CHECK static _Size
+ __hash_len_33_to_64(const char* __s, size_t __len) {
+ _Size __z = std::__loadword<_Size>(__s + 24);
+ _Size __a = std::__loadword<_Size>(__s) + (__len + std::__loadword<_Size>(__s + __len - 16)) * __k0;
+ _Size __b = __rotate(__a + __z, 52);
+ _Size __c = __rotate(__a, 37);
+ __a += std::__loadword<_Size>(__s + 8);
+ __c += __rotate(__a, 7);
+ __a += std::__loadword<_Size>(__s + 16);
+ _Size __vf = __a + __z;
+ _Size __vs = __b + __rotate(__a, 31) + __c;
+ __a = std::__loadword<_Size>(__s + 16) + std::__loadword<_Size>(__s + __len - 32);
+ __z += std::__loadword<_Size>(__s + __len - 8);
+ __b = __rotate(__a + __z, 52);
+ __c = __rotate(__a, 37);
+ __a += std::__loadword<_Size>(__s + __len - 24);
+ __c += __rotate(__a, 7);
+ __a += std::__loadword<_Size>(__s + __len - 16);
+ _Size __wf = __a + __z;
+ _Size __ws = __b + __rotate(__a, 31) + __c;
+ _Size __r = __shift_mix((__vf + __ws) * __k2 + (__wf + __vs) * __k0);
+ return __shift_mix(__r * __k0 + __vs) * __k2;
+ }
+};
+
+#if _LIBCPP_AVAILABILITY_HAS_HASH_MEMORY
+[[__gnu__::__pure__]] _LIBCPP_EXPORTED_FROM_ABI size_t __hash_memory(_LIBCPP_NOESCAPE const void*, size_t) _NOEXCEPT;
+#else
+_LIBCPP_HIDE_FROM_ABI inline size_t __hash_memory(const void* __ptr, size_t __size) _NOEXCEPT {
+ return __murmur2_or_cityhash<size_t>()(__ptr, __size);
+}
+#endif
+
+template <class _Tp, size_t = sizeof(_Tp) / sizeof(size_t)>
+struct __scalar_hash;
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 0> : public __unary_function<_Tp, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
+ union {
+ _Tp __t;
+ size_t __a;
+ } __u;
+ __u.__a = 0;
+ __u.__t = __v;
+ return __u.__a;
+ }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 1> : public __unary_function<_Tp, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
+ union {
+ _Tp __t;
+ size_t __a;
+ } __u;
+ __u.__t = __v;
+ return __u.__a;
+ }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 2> : public __unary_function<_Tp, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
+ union {
+ _Tp __t;
+ struct {
+ size_t __a;
+ size_t __b;
+ } __s;
+ } __u;
+ __u.__t = __v;
+ return std::__hash_memory(std::addressof(__u), sizeof(__u));
+ }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 3> : public __unary_function<_Tp, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
+ union {
+ _Tp __t;
+ struct {
+ size_t __a;
+ size_t __b;
+ size_t __c;
+ } __s;
+ } __u;
+ __u.__t = __v;
+ return std::__hash_memory(std::addressof(__u), sizeof(__u));
+ }
+};
+
+template <class _Tp>
+struct __scalar_hash<_Tp, 4> : public __unary_function<_Tp, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
+ union {
+ _Tp __t;
+ struct {
+ size_t __a;
+ size_t __b;
+ size_t __c;
+ size_t __d;
+ } __s;
+ } __u;
+ __u.__t = __v;
+ return std::__hash_memory(std::addressof(__u), sizeof(__u));
+ }
+};
+
+_LIBCPP_HIDE_FROM_ABI inline size_t __hash_combine(size_t __lhs, size_t __rhs) _NOEXCEPT {
+ typedef __scalar_hash<_PairT> _HashT;
+ const _PairT __p = {__lhs, __rhs};
+ return _HashT()(__p);
+}
+
+template <class _Tp>
+struct hash<_Tp*> : public __unary_function<_Tp*, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp* __v) const _NOEXCEPT {
+ union {
+ _Tp* __t;
+ size_t __a;
+ } __u;
+ __u.__t = __v;
+ return std::__hash_memory(std::addressof(__u), sizeof(__u));
+ }
+};
+
+template <class _Tp, class = void>
+struct __hash_impl {
+ __hash_impl() = delete;
+ __hash_impl(__hash_impl const&) = delete;
+ __hash_impl& operator=(__hash_impl const&) = delete;
+};
+
+template <class _Tp>
+struct __hash_impl<_Tp, __enable_if_t<is_enum<_Tp>::value && __is_unqualified_v<_Tp> > >
+ : __unary_function<_Tp, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
+ using type = __underlying_type_t<_Tp>;
+ return hash<type>()(static_cast<type>(__v));
+ }
+};
+
+template <class _Tp>
+struct __hash_impl<
+ _Tp,
+ __enable_if_t<is_integral<_Tp>::value && __is_unqualified_v<_Tp> && (sizeof(_Tp) <= sizeof(size_t))> >
+ : __unary_function<_Tp, size_t> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT { return static_cast<size_t>(__v); }
+};
+
+template <class _Tp>
+struct __hash_impl<_Tp,
+ __enable_if_t<is_integral<_Tp>::value && __is_unqualified_v<_Tp> && (sizeof(_Tp) > sizeof(size_t))> >
+ : __scalar_hash<_Tp> {};
+
+template <class _Tp>
+struct __hash_impl<_Tp, __enable_if_t<is_floating_point<_Tp>::value && __is_unqualified_v<_Tp> > >
+ : __scalar_hash<_Tp> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(_Tp __v) const _NOEXCEPT {
+ // -0.0 and 0.0 should return same hash
+ if (__v == 0.0f)
+ return 0;
+ return __scalar_hash<_Tp>::operator()(__v);
+ }
+};
+
+template <>
+struct __hash_impl<long double> : __scalar_hash<long double> {
+ _LIBCPP_HIDE_FROM_ABI size_t operator()(long double __v) const _NOEXCEPT {
+ // -0.0 and 0.0 should return same hash
+ if (__v == 0.0L)
+ return 0;
+#if defined(__i386__) || (defined(__x86_64__) && defined(__ILP32__))
+ // Zero out padding bits
+ union {
+ long double __t;
+ struct {
+ size_t __a;
+ size_t __b;
+ size_t __c;
+ size_t __d;
+ } __s;
+ } __u;
+ __u.__s.__a = 0;
+ __u.__s.__b = 0;
+ __u.__s.__c = 0;
+ __u.__s.__d = 0;
+ __u.__t = __v;
+ return __u.__s.__a ^ __u.__s.__b ^ __u.__s.__c ^ __u.__s.__d;
+#elif defined(__x86_64__)
+ // Zero out padding bits
+ union {
+ long double __t;
+ struct {
+ size_t __a;
+ size_t __b;
+ } __s;
+ } __u;
+ __u.__s.__a = 0;
+ __u.__s.__b = 0;
+ __u.__t = __v;
+ return __u.__s.__a ^ __u.__s.__b;
+#else
+ return __scalar_hash<long double>::operator()(__v);
+#endif
+ }
+};
+
+template <class _Tp>
+struct hash : public __hash_impl<_Tp> {};
+
+template <>
+struct hash<nullptr_t> : public __unary_function<nullptr_t, size_t> {
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI size_t operator()(nullptr_t) const _NOEXCEPT { return 662607004ull; }
+};
+
+#ifndef _LIBCPP_CXX03_LANG
+template <class _Key, class _Hash>
+using __check_hash_requirements _LIBCPP_NODEBUG =
+ integral_constant<bool,
+ is_copy_constructible<_Hash>::value && is_move_constructible<_Hash>::value &&
+ __is_invocable_r_v<size_t, _Hash, _Key const&> >;
+
+template <class _Key, class _Hash = hash<_Key> >
+using __has_enabled_hash _LIBCPP_NODEBUG =
+ integral_constant<bool, __check_hash_requirements<_Key, _Hash>::value && is_default_constructible<_Hash>::value >;
+
+template <class _Type, class>
+using __enable_hash_helper_imp _LIBCPP_NODEBUG = _Type;
+
+template <class _Type, class... _Keys>
+using __enable_hash_helper _LIBCPP_NODEBUG =
+ __enable_hash_helper_imp<_Type, __enable_if_t<__all<__has_enabled_hash<_Keys>::value...>::value> >;
+#endif // !_LIBCPP_CXX03_LANG
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_HASH_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/identity.h b/third_party/libcxx/include/c++/v1/__functional/identity.h
new file mode 100644
index 0000000..02dde2b
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/identity.h
@@ -0,0 +1,65 @@
+// -*- 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___FUNCTIONAL_IDENTITY_H
+#define _LIBCPP___FUNCTIONAL_IDENTITY_H
+
+#include <__config>
+#include <__fwd/functional.h>
+#include <__type_traits/integral_constant.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+struct __is_identity : false_type {};
+
+struct __identity {
+ template <class _Tp>
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR _Tp&& operator()(_Tp&& __t) const _NOEXCEPT {
+ return std::forward<_Tp>(__t);
+ }
+
+ using is_transparent = void;
+};
+
+template <>
+struct __is_identity<__identity> : true_type {};
+template <>
+struct __is_identity<reference_wrapper<__identity> > : true_type {};
+template <>
+struct __is_identity<reference_wrapper<const __identity> > : true_type {};
+
+#if _LIBCPP_STD_VER >= 20
+
+struct identity {
+ template <class _Tp>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_LIBCPP_LIFETIMEBOUND _Tp&& __t) const noexcept {
+ return std::forward<_Tp>(__t);
+ }
+
+ using is_transparent = void;
+};
+
+template <>
+struct __is_identity<identity> : true_type {};
+template <>
+struct __is_identity<reference_wrapper<identity> > : true_type {};
+template <>
+struct __is_identity<reference_wrapper<const identity> > : true_type {};
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_IDENTITY_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/invoke.h b/third_party/libcxx/include/c++/v1/__functional/invoke.h
new file mode 100644
index 0000000..ab201e9
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/invoke.h
@@ -0,0 +1,55 @@
+// -*- 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___FUNCTIONAL_INVOKE_H
+#define _LIBCPP___FUNCTIONAL_INVOKE_H
+
+#include <__config>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_void.h>
+#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 >= 17
+
+template <class _Fn, class... _Args>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 invoke_result_t<_Fn, _Args...>
+invoke(_Fn&& __f, _Args&&... __args) noexcept(is_nothrow_invocable_v<_Fn, _Args...>) {
+ return std::__invoke(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);
+}
+
+#endif // _LIBCPP_STD_VER >= 17
+
+#if _LIBCPP_STD_VER >= 23
+template <class _Result, class _Fn, class... _Args>
+ requires is_invocable_r_v<_Result, _Fn, _Args...>
+_LIBCPP_HIDE_FROM_ABI constexpr _Result
+invoke_r(_Fn&& __f, _Args&&... __args) noexcept(is_nothrow_invocable_r_v<_Result, _Fn, _Args...>) {
+ if constexpr (is_void_v<_Result>) {
+ static_cast<void>(std::invoke(std::forward<_Fn>(__f), std::forward<_Args>(__args)...));
+ } else {
+ // TODO: Use reference_converts_from_temporary_v once implemented
+ // using _ImplicitInvokeResult = invoke_result_t<_Fn, _Args...>;
+ // static_assert(!reference_converts_from_temporary_v<_Result, _ImplicitInvokeResult>,
+ static_assert(true,
+ "Returning from invoke_r would bind a temporary object to the reference return type, "
+ "which would result in a dangling reference.");
+ return std::invoke(std::forward<_Fn>(__f), std::forward<_Args>(__args)...);
+ }
+}
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_INVOKE_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/is_transparent.h b/third_party/libcxx/include/c++/v1/__functional/is_transparent.h
new file mode 100644
index 0000000..a62b4ca
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/is_transparent.h
@@ -0,0 +1,42 @@
+// -*- 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___FUNCTIONAL_IS_TRANSPARENT
+#define _LIBCPP___FUNCTIONAL_IS_TRANSPARENT
+
+#include <__config>
+#include <__type_traits/void_t.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER >= 14
+
+template <class _Comparator, class = void>
+inline const bool __is_transparent_v = false;
+
+template <class _Comparator>
+inline const bool __is_transparent_v<_Comparator, __void_t<typename _Comparator::is_transparent> > = true;
+
+#endif
+
+// Two types are considered transparently comparable if `comparator(key, arg)` is equivalent to `comparator(key,
+// <implicit cast to KeyT>(arg))`.
+//
+// This is different from `__is_transparent_v`, which is only a property of the comparator and doesn't provide
+// additional semantic guarantees.
+template <class _Comparator, class _KeyT, class _Arg, class = void>
+inline const bool __is_transparently_comparable_v = false;
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_IS_TRANSPARENT
diff --git a/third_party/libcxx/include/c++/v1/__functional/mem_fn.h b/third_party/libcxx/include/c++/v1/__functional/mem_fn.h
new file mode 100644
index 0000000..1c9340c
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/mem_fn.h
@@ -0,0 +1,53 @@
+// -*- 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___FUNCTIONAL_MEM_FN_H
+#define _LIBCPP___FUNCTIONAL_MEM_FN_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/weak_result_type.h>
+#include <__type_traits/invoke.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+class __mem_fn : public __weak_result_type<_Tp> {
+public:
+ // types
+ typedef _Tp type;
+
+private:
+ type __f_;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
+
+ // invoke
+ template <class... _ArgTypes>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<const _Tp&, _ArgTypes...>
+ operator()(_ArgTypes&&... __args) const _NOEXCEPT_(__is_nothrow_invocable_v<const _Tp&, _ArgTypes...>) {
+ return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
+ }
+};
+
+template <class _Rp, class _Tp>
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __mem_fn<_Rp _Tp::*>
+mem_fn(_Rp _Tp::* __pm) _NOEXCEPT {
+ return __mem_fn<_Rp _Tp::*>(__pm);
+}
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_MEM_FN_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/mem_fun_ref.h b/third_party/libcxx/include/c++/v1/__functional/mem_fun_ref.h
new file mode 100644
index 0000000..6822377
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/mem_fun_ref.h
@@ -0,0 +1,145 @@
+// -*- 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___FUNCTIONAL_MEM_FUN_REF_H
+#define _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class _Sp, class _Tp>
+class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t : public __unary_function<_Tp*, _Sp> {
+ _Sp (_Tp::*__p_)();
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit mem_fun_t(_Sp (_Tp::*__p)()) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(_Tp* __p) const { return (__p->*__p_)(); }
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t : public __binary_function<_Tp*, _Ap, _Sp> {
+ _Sp (_Tp::*__p_)(_Ap);
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap)) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(_Tp* __p, _Ap __x) const { return (__p->*__p_)(__x); }
+};
+
+template <class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun_t<_Sp, _Tp> mem_fun(_Sp (_Tp::*__f)()) {
+ return mem_fun_t<_Sp, _Tp>(__f);
+}
+
+template <class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun1_t<_Sp, _Tp, _Ap> mem_fun(_Sp (_Tp::*__f)(_Ap)) {
+ return mem_fun1_t<_Sp, _Tp, _Ap>(__f);
+}
+
+template <class _Sp, class _Tp>
+class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t : public __unary_function<_Tp, _Sp> {
+ _Sp (_Tp::*__p_)();
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit mem_fun_ref_t(_Sp (_Tp::*__p)()) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(_Tp& __p) const { return (__p.*__p_)(); }
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> {
+ _Sp (_Tp::*__p_)(_Ap);
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap)) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(_Tp& __p, _Ap __x) const { return (__p.*__p_)(__x); }
+};
+
+template <class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun_ref_t<_Sp, _Tp> mem_fun_ref(_Sp (_Tp::*__f)()) {
+ return mem_fun_ref_t<_Sp, _Tp>(__f);
+}
+
+template <class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI mem_fun1_ref_t<_Sp, _Tp, _Ap>
+mem_fun_ref(_Sp (_Tp::*__f)(_Ap)) {
+ return mem_fun1_ref_t<_Sp, _Tp, _Ap>(__f);
+}
+
+template <class _Sp, class _Tp>
+class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t : public __unary_function<const _Tp*, _Sp> {
+ _Sp (_Tp::*__p_)() const;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit const_mem_fun_t(_Sp (_Tp::*__p)() const) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(const _Tp* __p) const { return (__p->*__p_)(); }
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t : public __binary_function<const _Tp*, _Ap, _Sp> {
+ _Sp (_Tp::*__p_)(_Ap) const;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(const _Tp* __p, _Ap __x) const { return (__p->*__p_)(__x); }
+};
+
+template <class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI const_mem_fun_t<_Sp, _Tp> mem_fun(_Sp (_Tp::*__f)() const) {
+ return const_mem_fun_t<_Sp, _Tp>(__f);
+}
+
+template <class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI const_mem_fun1_t<_Sp, _Tp, _Ap>
+mem_fun(_Sp (_Tp::*__f)(_Ap) const) {
+ return const_mem_fun1_t<_Sp, _Tp, _Ap>(__f);
+}
+
+template <class _Sp, class _Tp>
+class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t : public __unary_function<_Tp, _Sp> {
+ _Sp (_Tp::*__p_)() const;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(const _Tp& __p) const { return (__p.*__p_)(); }
+};
+
+template <class _Sp, class _Tp, class _Ap>
+class _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t : public __binary_function<_Tp, _Ap, _Sp> {
+ _Sp (_Tp::*__p_)(_Ap) const;
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const) : __p_(__p) {}
+ _LIBCPP_HIDE_FROM_ABI _Sp operator()(const _Tp& __p, _Ap __x) const { return (__p.*__p_)(__x); }
+};
+
+template <class _Sp, class _Tp>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI const_mem_fun_ref_t<_Sp, _Tp>
+mem_fun_ref(_Sp (_Tp::*__f)() const) {
+ return const_mem_fun_ref_t<_Sp, _Tp>(__f);
+}
+
+template <class _Sp, class _Tp, class _Ap>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI const_mem_fun1_ref_t<_Sp, _Tp, _Ap>
+mem_fun_ref(_Sp (_Tp::*__f)(_Ap) const) {
+ return const_mem_fun1_ref_t<_Sp, _Tp, _Ap>(__f);
+}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_MEM_FUN_REF_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/not_fn.h b/third_party/libcxx/include/c++/v1/__functional/not_fn.h
new file mode 100644
index 0000000..e6f14be
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/not_fn.h
@@ -0,0 +1,76 @@
+// -*- 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___FUNCTIONAL_NOT_FN_H
+#define _LIBCPP___FUNCTIONAL_NOT_FN_H
+
+#include <__config>
+#include <__functional/invoke.h>
+#include <__functional/perfect_forward.h>
+#include <__type_traits/decay.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/is_constructible.h>
+#include <__type_traits/is_member_pointer.h>
+#include <__type_traits/is_pointer.h>
+#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 >= 17
+
+struct __not_fn_op {
+ template <class... _Args>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto operator()(_Args&&... __args) const
+ noexcept(noexcept(!std::invoke(std::forward<_Args>(__args)...)))
+ -> decltype(!std::invoke(std::forward<_Args>(__args)...)) {
+ return !std::invoke(std::forward<_Args>(__args)...);
+ }
+};
+
+template <class _Fn>
+struct __not_fn_t : __perfect_forward<__not_fn_op, _Fn> {
+ using __perfect_forward<__not_fn_op, _Fn>::__perfect_forward;
+};
+
+template <class _Fn,
+ class = enable_if_t< is_constructible_v<decay_t<_Fn>, _Fn> && is_move_constructible_v<decay_t<_Fn>> >>
+_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 auto not_fn(_Fn&& __f) {
+ return __not_fn_t<decay_t<_Fn>>(std::forward<_Fn>(__f));
+}
+
+#endif // _LIBCPP_STD_VER >= 17
+
+#if _LIBCPP_STD_VER >= 26
+
+template <auto _Fn>
+struct __nttp_not_fn_t {
+ template <class... _Args>
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const
+ noexcept(noexcept(!std::invoke(_Fn, std::forward<_Args>(__args)...)))
+ -> decltype(!std::invoke(_Fn, std::forward<_Args>(__args)...)) {
+ return !std::invoke(_Fn, std::forward<_Args>(__args)...);
+ }
+};
+
+template <auto _Fn>
+[[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI constexpr auto not_fn() noexcept {
+ if constexpr (using _Ty = decltype(_Fn); is_pointer_v<_Ty> || is_member_pointer_v<_Ty>)
+ static_assert(_Fn != nullptr, "f cannot be equal to nullptr");
+ return __nttp_not_fn_t<_Fn>();
+}
+
+#endif // _LIBCPP_STD_VER >= 26
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/operations.h b/third_party/libcxx/include/c++/v1/__functional/operations.h
new file mode 100644
index 0000000..7a80dce
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/operations.h
@@ -0,0 +1,569 @@
+// -*- 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___FUNCTIONAL_OPERATIONS_H
+#define _LIBCPP___FUNCTIONAL_OPERATIONS_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/unary_function.h>
+#include <__fwd/functional.h>
+#include <__type_traits/desugars_to.h>
+#include <__type_traits/is_generic_transparent_comparator.h>
+#include <__type_traits/is_integral.h>
+#include <__type_traits/make_transparent.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+// Arithmetic operations
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct plus : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x + __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
+
+// The non-transparent std::plus specialization is only equivalent to a raw plus
+// operator when we don't perform an implicit conversion when calling it.
+template <class _Tp>
+inline const bool __desugars_to_v<__plus_tag, plus<_Tp>, _Tp, _Tp> = true;
+
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__plus_tag, plus<void>, _Tp, _Up> = true;
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct plus<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) + std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) + std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) + std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct minus : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x - __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(minus);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct minus<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) - std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) - std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) - std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct multiplies : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x * __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(multiplies);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct multiplies<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) * std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) * std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) * std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct divides : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x / __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(divides);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct divides<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) / std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) / std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) / std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct modulus : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x % __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(modulus);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct modulus<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) % std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) % std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) % std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct negate : __unary_function<_Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return -__x; }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct negate<void> {
+ template <class _Tp>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
+ noexcept(noexcept(-std::forward<_Tp>(__x))) //
+ -> decltype(-std::forward<_Tp>(__x)) {
+ return -std::forward<_Tp>(__x);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+// Bitwise operations
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct bit_and : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x & __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_and);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct bit_and<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) &
+ std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) & std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) & std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+struct bit_not : __unary_function<_Tp, _Tp> {
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x) const { return ~__x; }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
+
+template <>
+struct bit_not<void> {
+ template <class _Tp>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
+ noexcept(noexcept(~std::forward<_Tp>(__x))) //
+ -> decltype(~std::forward<_Tp>(__x)) {
+ return ~std::forward<_Tp>(__x);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct bit_or : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x | __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_or);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct bit_or<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) | std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) | std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) | std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct bit_xor : __binary_function<_Tp, _Tp, _Tp> {
+ typedef _Tp __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI _Tp operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x ^ __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_xor);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct bit_xor<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) ^ std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) ^ std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) ^ std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+// Comparison operations
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct equal_to : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x == __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(equal_to);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct equal_to<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) == std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) == std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) == std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+// The non-transparent std::equal_to specialization is only equivalent to a raw equality
+// comparison when we don't perform an implicit conversion when calling it.
+template <class _Tp>
+inline const bool __desugars_to_v<__equal_tag, equal_to<_Tp>, _Tp, _Tp> = true;
+
+// In the transparent case, we do not enforce that
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__equal_tag, equal_to<void>, _Tp, _Up> = true;
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct not_equal_to : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x != __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(not_equal_to);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct not_equal_to<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) != std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) != std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) != std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+template <class _Tp>
+struct less : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x < __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
+
+template <class _Tp>
+inline const bool __desugars_to_v<__less_tag, less<_Tp>, _Tp, _Tp> = true;
+
+template <class _Tp>
+inline const bool __desugars_to_v<__totally_ordered_less_tag, less<_Tp>, _Tp, _Tp> = is_integral<_Tp>::value;
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct less<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) < std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) < std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) < std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+
+template <class _ArgumentType>
+struct __make_transparent<_ArgumentType, less<_ArgumentType> > {
+ using type _LIBCPP_NODEBUG = less<>;
+};
+
+template <>
+inline const bool __is_generic_transparent_comparator_v<less<>> = true;
+
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__less_tag, less<>, _Tp, _Up> = true;
+
+template <class _Tp>
+inline const bool __desugars_to_v<__totally_ordered_less_tag, less<>, _Tp, _Tp> = is_integral<_Tp>::value;
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct less_equal : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x <= __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less_equal);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct less_equal<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) <= std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) <= std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) <= std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct greater_equal : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x >= __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater_equal);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct greater_equal<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) >=
+ std::forward<_T2>(__u))) -> decltype(std::forward<_T1>(__t) >= std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) >= std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct greater : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x > __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
+
+template <class _Tp>
+inline const bool __desugars_to_v<__greater_tag, greater<_Tp>, _Tp, _Tp> = true;
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct greater<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) > std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) > std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) > std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__greater_tag, greater<>, _Tp, _Up> = true;
+
+template <class _ArgumentType>
+struct __make_transparent<_ArgumentType, greater<_ArgumentType>> {
+ using type _LIBCPP_NODEBUG = greater<>;
+};
+
+template <>
+inline const bool __is_generic_transparent_comparator_v<greater<>> = true;
+#endif
+
+// Logical operations
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct logical_and : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x && __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_and);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct logical_and<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) && std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) && std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) && std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct logical_not : __unary_function<_Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x) const { return !__x; }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct logical_not<void> {
+ template <class _Tp>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_Tp&& __x) const
+ noexcept(noexcept(!std::forward<_Tp>(__x))) //
+ -> decltype(!std::forward<_Tp>(__x)) {
+ return !std::forward<_Tp>(__x);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+#if _LIBCPP_STD_VER >= 14
+template <class _Tp = void>
+#else
+template <class _Tp>
+#endif
+struct logical_or : __binary_function<_Tp, _Tp, bool> {
+ typedef bool __result_type; // used by valarray
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool operator()(const _Tp& __x, const _Tp& __y) const {
+ return __x || __y;
+ }
+};
+_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_or);
+
+#if _LIBCPP_STD_VER >= 14
+template <>
+struct logical_or<void> {
+ template <class _T1, class _T2>
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI auto operator()(_T1&& __t, _T2&& __u) const
+ noexcept(noexcept(std::forward<_T1>(__t) || std::forward<_T2>(__u))) //
+ -> decltype(std::forward<_T1>(__t) || std::forward<_T2>(__u)) {
+ return std::forward<_T1>(__t) || std::forward<_T2>(__u);
+ }
+ typedef void is_transparent;
+};
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/perfect_forward.h b/third_party/libcxx/include/c++/v1/__functional/perfect_forward.h
new file mode 100644
index 0000000..37c3d15
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/perfect_forward.h
@@ -0,0 +1,105 @@
+// -*- 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___FUNCTIONAL_PERFECT_FORWARD_H
+#define _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
+
+#include <__config>
+#include <__cstddef/size_t.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_constructible.h>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+#include <__utility/integer_sequence.h>
+#include <__utility/move.h>
+#include <tuple>
+
+#if !defined(_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 >= 17
+
+template <class _Op, class _Indices, class... _BoundArgs>
+struct __perfect_forward_impl;
+
+template <class _Op, size_t... _Idx, class... _BoundArgs>
+struct __perfect_forward_impl<_Op, index_sequence<_Idx...>, _BoundArgs...> {
+private:
+ tuple<_BoundArgs...> __bound_args_;
+
+public:
+ template <class... _Args, class = enable_if_t< is_constructible_v<tuple<_BoundArgs...>, _Args&&...> >>
+ _LIBCPP_HIDE_FROM_ABI explicit constexpr __perfect_forward_impl(_Args&&... __bound_args)
+ : __bound_args_(std::forward<_Args>(__bound_args)...) {}
+
+ _LIBCPP_HIDE_FROM_ABI __perfect_forward_impl(__perfect_forward_impl const&) = default;
+ _LIBCPP_HIDE_FROM_ABI __perfect_forward_impl(__perfect_forward_impl&&) = default;
+
+ _LIBCPP_HIDE_FROM_ABI __perfect_forward_impl& operator=(__perfect_forward_impl const&) = default;
+ _LIBCPP_HIDE_FROM_ABI __perfect_forward_impl& operator=(__perfect_forward_impl&&) = default;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) & noexcept(
+ noexcept(_Op()(std::get<_Idx>(__bound_args_)..., std::forward<_Args>(__args)...)))
+ -> decltype(_Op()(std::get<_Idx>(__bound_args_)..., std::forward<_Args>(__args)...)) {
+ return _Op()(std::get<_Idx>(__bound_args_)..., std::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs&..., _Args...>>>
+ auto operator()(_Args&&...) & = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const& noexcept(
+ noexcept(_Op()(std::get<_Idx>(__bound_args_)..., std::forward<_Args>(__args)...)))
+ -> decltype(_Op()(std::get<_Idx>(__bound_args_)..., std::forward<_Args>(__args)...)) {
+ return _Op()(std::get<_Idx>(__bound_args_)..., std::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const&..., _Args...>>>
+ auto operator()(_Args&&...) const& = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) && noexcept(
+ noexcept(_Op()(std::get<_Idx>(std::move(__bound_args_))..., std::forward<_Args>(__args)...)))
+ -> decltype(_Op()(std::get<_Idx>(std::move(__bound_args_))..., std::forward<_Args>(__args)...)) {
+ return _Op()(std::get<_Idx>(std::move(__bound_args_))..., std::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs..., _Args...>>>
+ auto operator()(_Args&&...) && = delete;
+
+ template <class... _Args, class = enable_if_t<is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ _LIBCPP_HIDE_FROM_ABI constexpr auto operator()(_Args&&... __args) const&& noexcept(
+ noexcept(_Op()(std::get<_Idx>(std::move(__bound_args_))..., std::forward<_Args>(__args)...)))
+ -> decltype(_Op()(std::get<_Idx>(std::move(__bound_args_))..., std::forward<_Args>(__args)...)) {
+ return _Op()(std::get<_Idx>(std::move(__bound_args_))..., std::forward<_Args>(__args)...);
+ }
+
+ template <class... _Args, class = enable_if_t<!is_invocable_v<_Op, _BoundArgs const..., _Args...>>>
+ auto operator()(_Args&&...) const&& = delete;
+};
+
+// __perfect_forward implements a perfect-forwarding call wrapper as explained in [func.require].
+template <class _Op, class... _Args>
+using __perfect_forward _LIBCPP_NODEBUG = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>;
+
+#endif // _LIBCPP_STD_VER >= 17
+
+_LIBCPP_END_NAMESPACE_STD
+
+_LIBCPP_POP_MACROS
+
+#endif // _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/pointer_to_binary_function.h b/third_party/libcxx/include/c++/v1/__functional/pointer_to_binary_function.h
new file mode 100644
index 0000000..eb0e767
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/pointer_to_binary_function.h
@@ -0,0 +1,43 @@
+// -*- 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___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class _Arg1, class _Arg2, class _Result>
+class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function : public __binary_function<_Arg1, _Arg2, _Result> {
+ _Result (*__f_)(_Arg1, _Arg2);
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2)) : __f_(__f) {}
+ _LIBCPP_HIDE_FROM_ABI _Result operator()(_Arg1 __x, _Arg2 __y) const { return __f_(__x, __y); }
+};
+
+template <class _Arg1, class _Arg2, class _Result>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI pointer_to_binary_function<_Arg1, _Arg2, _Result>
+ptr_fun(_Result (*__f)(_Arg1, _Arg2)) {
+ return pointer_to_binary_function<_Arg1, _Arg2, _Result>(__f);
+}
+
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_BINARY_FUNCTION_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/pointer_to_unary_function.h b/third_party/libcxx/include/c++/v1/__functional/pointer_to_unary_function.h
new file mode 100644
index 0000000..459d24a
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/pointer_to_unary_function.h
@@ -0,0 +1,43 @@
+// -*- 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___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+template <class _Arg, class _Result>
+class _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function : public __unary_function<_Arg, _Result> {
+ _Result (*__f_)(_Arg);
+
+public:
+ _LIBCPP_HIDE_FROM_ABI explicit pointer_to_unary_function(_Result (*__f)(_Arg)) : __f_(__f) {}
+ _LIBCPP_HIDE_FROM_ABI _Result operator()(_Arg __x) const { return __f_(__x); }
+};
+
+template <class _Arg, class _Result>
+_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_HIDE_FROM_ABI pointer_to_unary_function<_Arg, _Result>
+ptr_fun(_Result (*__f)(_Arg)) {
+ return pointer_to_unary_function<_Arg, _Result>(__f);
+}
+
+#endif // _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_BINDERS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_POINTER_TO_UNARY_FUNCTION_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/ranges_operations.h b/third_party/libcxx/include/c++/v1/__functional/ranges_operations.h
new file mode 100644
index 0000000..dc9da06
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/ranges_operations.h
@@ -0,0 +1,122 @@
+// -*- 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___FUNCTIONAL_RANGES_OPERATIONS_H
+#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
+
+#include <__concepts/equality_comparable.h>
+#include <__concepts/totally_ordered.h>
+#include <__config>
+#include <__type_traits/desugars_to.h>
+#include <__type_traits/is_generic_transparent_comparator.h>
+#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
+
+namespace ranges {
+
+struct equal_to {
+ template <class _Tp, class _Up>
+ requires equality_comparable_with<_Tp, _Up>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(bool(std::forward<_Tp>(__t) == std::forward<_Up>(__u)))) {
+ return std::forward<_Tp>(__t) == std::forward<_Up>(__u);
+ }
+
+ using is_transparent = void;
+};
+
+struct not_equal_to {
+ template <class _Tp, class _Up>
+ requires equality_comparable_with<_Tp, _Up>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(bool(!(std::forward<_Tp>(__t) == std::forward<_Up>(__u))))) {
+ return !(std::forward<_Tp>(__t) == std::forward<_Up>(__u));
+ }
+
+ using is_transparent = void;
+};
+
+struct less {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(bool(std::forward<_Tp>(__t) < std::forward<_Up>(__u)))) {
+ return std::forward<_Tp>(__t) < std::forward<_Up>(__u);
+ }
+
+ using is_transparent = void;
+};
+
+struct less_equal {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(bool(!(std::forward<_Up>(__u) < std::forward<_Tp>(__t))))) {
+ return !(std::forward<_Up>(__u) < std::forward<_Tp>(__t));
+ }
+
+ using is_transparent = void;
+};
+
+struct greater {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(bool(std::forward<_Up>(__u) < std::forward<_Tp>(__t)))) {
+ return std::forward<_Up>(__u) < std::forward<_Tp>(__t);
+ }
+
+ using is_transparent = void;
+};
+
+struct greater_equal {
+ template <class _Tp, class _Up>
+ requires totally_ordered_with<_Tp, _Up>
+ [[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr bool operator()(_Tp&& __t, _Up&& __u) const
+ noexcept(noexcept(bool(!(std::forward<_Tp>(__t) < std::forward<_Up>(__u))))) {
+ return !(std::forward<_Tp>(__t) < std::forward<_Up>(__u));
+ }
+
+ using is_transparent = void;
+};
+
+} // namespace ranges
+
+// For ranges we do not require that the types on each side of the equality
+// operator are of the same type
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__equal_tag, ranges::equal_to, _Tp, _Up> = true;
+
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__totally_ordered_less_tag, ranges::less, _Tp, _Up> = true;
+
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__less_tag, ranges::less, _Tp, _Up> = true;
+
+template <class _Tp, class _Up>
+inline const bool __desugars_to_v<__greater_tag, ranges::greater, _Tp, _Up> = true;
+
+template <>
+inline const bool __is_generic_transparent_comparator_v<ranges::less> = true;
+
+template <>
+inline const bool __is_generic_transparent_comparator_v<ranges::greater> = true;
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/reference_wrapper.h b/third_party/libcxx/include/c++/v1/__functional/reference_wrapper.h
new file mode 100644
index 0000000..b1efd9f
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/reference_wrapper.h
@@ -0,0 +1,192 @@
+// -*- 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___FUNCTIONAL_REFERENCE_WRAPPER_H
+#define _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
+
+#include <__compare/synth_three_way.h>
+#include <__concepts/convertible_to.h>
+#include <__config>
+#include <__functional/weak_result_type.h>
+#include <__memory/addressof.h>
+#include <__type_traits/common_reference.h>
+#include <__type_traits/desugars_to.h>
+#include <__type_traits/enable_if.h>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_const.h>
+#include <__type_traits/is_core_convertible.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/is_specialization.h>
+#include <__type_traits/remove_cvref.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
+#include <__utility/forward.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp>
+class reference_wrapper : public __weak_result_type<_Tp> {
+public:
+ // types
+ typedef _Tp type;
+
+private:
+ type* __f_;
+
+ static void __fun(_Tp&) _NOEXCEPT;
+ static void __fun(_Tp&&) = delete; // NOLINT(modernize-use-equals-delete) ; This is llvm.org/PR54276
+
+public:
+ template <class _Up,
+ class = __void_t<decltype(__fun(std::declval<_Up>()))>,
+ __enable_if_t<!is_same<__remove_cvref_t<_Up>, reference_wrapper>::value, int> = 0>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper(_Up&& __u)
+ _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
+ type& __f = static_cast<_Up&&>(__u);
+ __f_ = std::addressof(__f);
+ }
+
+ // access
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 operator type&() const _NOEXCEPT { return *__f_; }
+ [[__nodiscard__]] _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 type& get() const _NOEXCEPT { return *__f_; }
+
+ // invoke
+ template <class... _ArgTypes>
+ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<type&, _ArgTypes...>
+ operator()(_ArgTypes&&... __args) const
+#if _LIBCPP_STD_VER >= 17
+ // Since is_nothrow_invocable requires C++17 LWG3764 is not backported
+ // to earlier versions.
+ noexcept(is_nothrow_invocable_v<_Tp&, _ArgTypes...>)
+#endif
+ {
+ return std::__invoke(get(), std::forward<_ArgTypes>(__args)...);
+ }
+
+#if _LIBCPP_STD_VER >= 26
+
+ // [refwrap.comparisons], comparisons
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper __y)
+ requires requires {
+ { __x.get() == __y.get() } -> __core_convertible_to<bool>;
+ }
+ {
+ return __x.get() == __y.get();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, const _Tp& __y)
+ requires requires {
+ { __x.get() == __y } -> __core_convertible_to<bool>;
+ }
+ {
+ return __x.get() == __y;
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr bool operator==(reference_wrapper __x, reference_wrapper<const _Tp> __y)
+ requires(!is_const_v<_Tp>) && requires {
+ { __x.get() == __y.get() } -> __core_convertible_to<bool>;
+ }
+ {
+ return __x.get() == __y.get();
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper __y)
+ requires requires { std::__synth_three_way(__x.get(), __y.get()); }
+ {
+ return std::__synth_three_way(__x.get(), __y.get());
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, const _Tp& __y)
+ requires requires { std::__synth_three_way(__x.get(), __y); }
+ {
+ return std::__synth_three_way(__x.get(), __y);
+ }
+
+ _LIBCPP_HIDE_FROM_ABI friend constexpr auto operator<=>(reference_wrapper __x, reference_wrapper<const _Tp> __y)
+ requires(!is_const_v<_Tp>) && requires { std::__synth_three_way(__x.get(), __y.get()); }
+ {
+ return std::__synth_three_way(__x.get(), __y.get());
+ }
+
+#endif // _LIBCPP_STD_VER >= 26
+};
+
+#if _LIBCPP_STD_VER >= 17
+template <class _Tp>
+reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
+#endif
+
+template <class _Tp>
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI
+_LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<_Tp> ref(_Tp& __t) _NOEXCEPT {
+ return reference_wrapper<_Tp>(__t);
+}
+
+template <class _Tp>
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<_Tp>
+ref(reference_wrapper<_Tp> __t) _NOEXCEPT {
+ return __t;
+}
+
+template <class _Tp>
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<const _Tp>
+cref(const _Tp& __t) _NOEXCEPT {
+ return reference_wrapper<const _Tp>(__t);
+}
+
+template <class _Tp>
+[[__nodiscard__]] inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 reference_wrapper<const _Tp>
+cref(reference_wrapper<_Tp> __t) _NOEXCEPT {
+ return __t;
+}
+
+template <class _Tp>
+void ref(const _Tp&&) = delete;
+template <class _Tp>
+void cref(const _Tp&&) = delete;
+
+// Let desugars-to pass through std::reference_wrapper
+template <class _CanonicalTag, class _Operation, class... _Args>
+inline const bool __desugars_to_v<_CanonicalTag, reference_wrapper<_Operation>, _Args...> =
+ __desugars_to_v<_CanonicalTag, _Operation, _Args...>;
+
+#if _LIBCPP_STD_VER >= 20
+
+template <class _Tp>
+inline constexpr bool __is_ref_wrapper = __is_specialization_v<_Tp, reference_wrapper>;
+
+template <class _Rp, class _Tp, class _RpQual, class _TpQual>
+concept __ref_wrap_common_reference_exists_with = __is_ref_wrapper<_Rp> && requires {
+ typename common_reference_t<typename _Rp::type&, _TpQual>;
+} && convertible_to<_RpQual, common_reference_t<typename _Rp::type&, _TpQual>>;
+
+template <class _Rp, class _Tp, template <class> class _RpQual, template <class> class _TpQual>
+ requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> &&
+ !__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>)
+struct basic_common_reference<_Rp, _Tp, _RpQual, _TpQual> {
+ using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>;
+};
+
+template <class _Tp, class _Rp, template <class> class _TpQual, template <class> class _RpQual>
+ requires(__ref_wrap_common_reference_exists_with<_Rp, _Tp, _RpQual<_Rp>, _TpQual<_Tp>> &&
+ !__ref_wrap_common_reference_exists_with<_Tp, _Rp, _TpQual<_Tp>, _RpQual<_Rp>>)
+struct basic_common_reference<_Tp, _Rp, _TpQual, _RpQual> {
+ using type _LIBCPP_NODEBUG = common_reference_t<typename _Rp::type&, _TpQual<_Tp>>;
+};
+
+#endif // _LIBCPP_STD_VER >= 20
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/unary_function.h b/third_party/libcxx/include/c++/v1/__functional/unary_function.h
new file mode 100644
index 0000000..d6d5fae
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/unary_function.h
@@ -0,0 +1,50 @@
+//===----------------------------------------------------------------------===//
+//
+// 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___FUNCTIONAL_UNARY_FUNCTION_H
+#define _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
+
+#include <__config>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+
+template <class _Arg, class _Result>
+struct _LIBCPP_DEPRECATED_IN_CXX11 unary_function {
+ typedef _Arg argument_type;
+ typedef _Result result_type;
+};
+
+#endif // _LIBCPP_STD_VER <= 14
+
+template <class _Arg, class _Result>
+struct __unary_function_keep_layout_base {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using argument_type _LIBCPP_DEPRECATED_IN_CXX17 = _Arg;
+ using result_type _LIBCPP_DEPRECATED_IN_CXX17 = _Result;
+#endif
+};
+
+#if _LIBCPP_STD_VER <= 14 || defined(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Arg, class _Result>
+using __unary_function _LIBCPP_NODEBUG = unary_function<_Arg, _Result>;
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+#else
+template <class _Arg, class _Result>
+using __unary_function _LIBCPP_NODEBUG = __unary_function_keep_layout_base<_Arg, _Result>;
+#endif
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/unary_negate.h b/third_party/libcxx/include/c++/v1/__functional/unary_negate.h
new file mode 100644
index 0000000..a93abc8
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/unary_negate.h
@@ -0,0 +1,47 @@
+// -*- 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___FUNCTIONAL_UNARY_NEGATE_H
+#define _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H
+
+#include <__config>
+#include <__functional/unary_function.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+template <class _Predicate>
+class _LIBCPP_DEPRECATED_IN_CXX17 unary_negate : public __unary_function<typename _Predicate::argument_type, bool> {
+ _Predicate __pred_;
+
+public:
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI explicit unary_negate(const _Predicate& __pred)
+ : __pred_(__pred) {}
+ _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI bool
+ operator()(const typename _Predicate::argument_type& __x) const {
+ return !__pred_(__x);
+ }
+};
+
+template <class _Predicate>
+_LIBCPP_DEPRECATED_IN_CXX17 inline _LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_HIDE_FROM_ABI unary_negate<_Predicate>
+not1(const _Predicate& __pred) {
+ return unary_negate<_Predicate>(__pred);
+}
+
+#endif // _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_NEGATORS)
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_UNARY_NEGATE_H
diff --git a/third_party/libcxx/include/c++/v1/__functional/weak_result_type.h b/third_party/libcxx/include/c++/v1/__functional/weak_result_type.h
new file mode 100644
index 0000000..4232bdc
--- /dev/null
+++ b/third_party/libcxx/include/c++/v1/__functional/weak_result_type.h
@@ -0,0 +1,214 @@
+// -*- 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___FUNCTIONAL_WEAK_RESULT_TYPE_H
+#define _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H
+
+#include <__config>
+#include <__functional/binary_function.h>
+#include <__functional/unary_function.h>
+#include <__type_traits/invoke.h>
+#include <__type_traits/is_same.h>
+#include <__type_traits/void_t.h>
+#include <__utility/declval.h>
+
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+# pragma GCC system_header
+#endif
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+template <class _Tp, class = void>
+inline const bool __has_result_type_v = false;
+
+template <class _Tp>
+inline const bool __has_result_type_v<_Tp, __void_t<typename _Tp::result_type*> > = true;
+
+// __weak_result_type
+
+template <class _Tp>
+struct __derives_from_unary_function {
+private:
+ static void __find_base(...);
+ template <class _Ap, class _Rp>
+ static __unary_function<_Ap, _Rp> __find_base(const volatile __unary_function<_Ap, _Rp>*);
+
+public:
+ using type = decltype(__find_base(static_cast<_Tp*>(nullptr)));
+ static const bool value = !is_same<type, void>::value;
+};
+
+template <class _Tp>
+struct __derives_from_binary_function {
+private:
+ static void __find_base(...);
+ template <class _A1, class _A2, class _Rp>
+ static __binary_function<_A1, _A2, _Rp> __find_base(const volatile __binary_function<_A1, _A2, _Rp>*);
+
+public:
+ using type = decltype(__find_base(static_cast<_Tp*>(nullptr)));
+ static const bool value = !is_same<type, void>::value;
+};
+
+template <class _Tp, bool = __derives_from_unary_function<_Tp>::value>
+struct __maybe_derive_from_unary_function // bool is true
+ : public __derives_from_unary_function<_Tp>::type {};
+
+template <class _Tp>
+struct __maybe_derive_from_unary_function<_Tp, false> {};
+
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
+template <class _Tp, bool = __derives_from_binary_function<_Tp>::value>
+struct __maybe_derive_from_binary_function // bool is true
+ : public __derives_from_binary_function<_Tp>::type {};
+
+template <class _Tp>
+struct __maybe_derive_from_binary_function<_Tp, false> {};
+
+template <class _Tp, bool = __has_result_type_v<_Tp> >
+struct __weak_result_type_imp // bool is true
+ : public __maybe_derive_from_unary_function<_Tp>,
+ public __maybe_derive_from_binary_function<_Tp> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = typename _Tp::result_type;
+#endif
+};
+
+template <class _Tp>
+struct __weak_result_type_imp<_Tp, false>
+ : public __maybe_derive_from_unary_function<_Tp>, public __maybe_derive_from_binary_function<_Tp> {};
+
+template <class _Tp>
+struct __weak_result_type : public __weak_result_type_imp<_Tp> {};
+_LIBCPP_SUPPRESS_DEPRECATED_POP
+
+// 0 argument case
+
+template <class _Rp>
+struct __weak_result_type<_Rp()> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp>
+struct __weak_result_type<_Rp (&)()> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp>
+struct __weak_result_type<_Rp (*)()> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+// 1 argument case
+
+template <class _Rp, class _A1>
+struct __weak_result_type<_Rp(_A1)> : public __unary_function<_A1, _Rp> {};
+
+template <class _Rp, class _A1>
+struct __weak_result_type<_Rp (&)(_A1)> : public __unary_function<_A1, _Rp> {};
+
+template <class _Rp, class _A1>
+struct __weak_result_type<_Rp (*)(_A1)> : public __unary_function<_A1, _Rp> {};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)()> : public __unary_function<_Cp*, _Rp> {};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)() const> : public __unary_function<const _Cp*, _Rp> {};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)() volatile> : public __unary_function<volatile _Cp*, _Rp> {};
+
+template <class _Rp, class _Cp>
+struct __weak_result_type<_Rp (_Cp::*)() const volatile> : public __unary_function<const volatile _Cp*, _Rp> {};
+
+// 2 argument case
+
+template <class _Rp, class _A1, class _A2>
+struct __weak_result_type<_Rp(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {};
+
+template <class _Rp, class _A1, class _A2>
+struct __weak_result_type<_Rp (*)(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {};
+
+template <class _Rp, class _A1, class _A2>
+struct __weak_result_type<_Rp (&)(_A1, _A2)> : public __binary_function<_A1, _A2, _Rp> {};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1)> : public __binary_function<_Cp*, _A1, _Rp> {};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1) const> : public __binary_function<const _Cp*, _A1, _Rp> {};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1) volatile> : public __binary_function<volatile _Cp*, _A1, _Rp> {};
+
+template <class _Rp, class _Cp, class _A1>
+struct __weak_result_type<_Rp (_Cp::*)(_A1) const volatile> : public __binary_function<const volatile _Cp*, _A1, _Rp> {
+};
+
+// 3 or more arguments
+
+template <class _Rp, class _A1, class _A2, class _A3, class... _A4>
+struct __weak_result_type<_Rp(_A1, _A2, _A3, _A4...)> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp, class _A1, class _A2, class _A3, class... _A4>
+struct __weak_result_type<_Rp (&)(_A1, _A2, _A3, _A4...)> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp, class _A1, class _A2, class _A3, class... _A4>
+struct __weak_result_type<_Rp (*)(_A1, _A2, _A3, _A4...)> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class... _A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...)> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class... _A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class... _A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) volatile> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+template <class _Rp, class _Cp, class _A1, class _A2, class... _A3>
+struct __weak_result_type<_Rp (_Cp::*)(_A1, _A2, _A3...) const volatile> {
+#if _LIBCPP_STD_VER <= 17 || defined(_LIBCPP_ENABLE_CXX20_REMOVED_BINDER_TYPEDEFS)
+ using result_type _LIBCPP_NODEBUG _LIBCPP_DEPRECATED_IN_CXX17 = _Rp;
+#endif
+};
+
+_LIBCPP_END_NAMESPACE_STD
+
+#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H