Upgrade to 2022-era LLVM LIBCXX

This commit is contained in:
Justine Tunney 2024-05-27 02:12:27 -07:00
parent 2f4ca71f26
commit 8e68384e15
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
2078 changed files with 165657 additions and 65010 deletions

View file

@ -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_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_TEMPLATE_VIS _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_DIAGNOSTIC_PUSH
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
template <class _Arg1, class _Arg2, class _Result>
using __binary_function = binary_function<_Arg1, _Arg2, _Result>;
_LIBCPP_DIAGNOSTIC_POP
#else
template <class _Arg1, class _Arg2, class _Result>
using __binary_function = __binary_function_keep_layout_base<_Arg1, _Arg2, _Result>;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_BINARY_FUNCTION_H

View file

@ -0,0 +1,50 @@
// -*- 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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 binary_negate
: public __binary_function<typename _Predicate::first_argument_type,
typename _Predicate::second_argument_type,
bool>
{
_Predicate __pred_;
public:
_LIBCPP_INLINE_VISIBILITY explicit _LIBCPP_CONSTEXPR_SINCE_CXX14
binary_negate(const _Predicate& __pred) : __pred_(__pred) {}
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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_INLINE_VISIBILITY
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

386
third_party/libcxx/__functional/bind.h vendored Normal file
View file

@ -0,0 +1,386 @@
// -*- 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/invoke.h>
#include <__functional/weak_result_type.h>
#include <__type_traits/decay.h>
#include <__type_traits/is_reference_wrapper.h>
#include <__type_traits/is_void.h>
#include <cstddef>
#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_FUNC_VIS extern const __ph<1> _1;
_LIBCPP_FUNC_VIS extern const __ph<2> _2;
_LIBCPP_FUNC_VIS extern const __ph<3> _3;
_LIBCPP_FUNC_VIS extern const __ph<4> _4;
_LIBCPP_FUNC_VIS extern const __ph<5> _5;
_LIBCPP_FUNC_VIS extern const __ph<6> _6;
_LIBCPP_FUNC_VIS extern const __ph<7> _7;
_LIBCPP_FUNC_VIS extern const __ph<8> _8;
_LIBCPP_FUNC_VIS extern const __ph<9> _9;
_LIBCPP_FUNC_VIS 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_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
_Tp&
__mu(reference_wrapper<_Tp> __t, _Uj&)
{
return __t.get();
}
template <class _Ti, class ..._Uj, size_t ..._Indx>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __invoke_of<_Ti&, _Uj...>::type
__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>)
{
return __ti(_VSTD::forward<_Uj>(_VSTD::get<_Indx>(__uj))...);
}
template <class _Ti, class ..._Uj>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __enable_if_t
<
is_bind_expression<_Ti>::value,
__invoke_of<_Ti&, _Uj...>
>::type
__mu(_Ti& __ti, tuple<_Uj...>& __uj)
{
typedef typename __make_tuple_indices<sizeof...(_Uj)>::type __indices;
return _VSTD::__mu_expand(__ti, __uj, __indices());
}
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>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
0 < is_placeholder<_Ti>::value,
typename __mu_return2<0 < is_placeholder<_Ti>::value, _Ti, _Uj>::type
>::type
__mu(_Ti&, _Uj& __uj)
{
const size_t __indx = is_placeholder<_Ti>::value - 1;
return _VSTD::forward<typename tuple_element<__indx, _Uj>::type>(_VSTD::get<__indx>(__uj));
}
template <class _Ti, class _Uj>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
!is_bind_expression<_Ti>::value &&
is_placeholder<_Ti>::value == 0 &&
!__is_reference_wrapper<_Ti>::value,
_Ti&
>::type
__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...>
{
typedef typename __invoke_of<_Ti&, _Uj...>::type type;
};
template <class _Ti, class ..._Uj>
struct __mu_return_impl<_Ti, false, true, false, tuple<_Uj...> >
: public __mu_return_invokable<__invokable<_Ti&, _Uj...>::value, _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 = __invokable<_Fp,
typename __mu_return<_BoundArgs, _TupleUj>::type...>::value;
};
template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __is_valid_bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj>
{
static const bool value = __invokable<_Fp,
typename __mu_return<const _BoundArgs, _TupleUj>::type...>::value;
};
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>
{
typedef typename __invoke_of
<
_Fp&,
typename __mu_return
<
_BoundArgs,
_TupleUj
>::type...
>::type type;
};
template <class _Fp, class ..._BoundArgs, class _TupleUj>
struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true>
{
typedef typename __invoke_of
<
_Fp&,
typename __mu_return
<
const _BoundArgs,
_TupleUj
>::type...
>::type type;
};
template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __bind_return<_Fp, _BoundArgs, _Args>::type
__apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>,
_Args&& __args)
{
return _VSTD::__invoke(__f, _VSTD::__mu(_VSTD::get<_Indx>(__bound_args), __args)...);
}
template<class _Fp, class ..._BoundArgs>
class __bind : public __weak_result_type<__decay_t<_Fp> >
{
protected:
using _Fd = __decay_t<_Fp>;
typedef tuple<__decay_t<_BoundArgs>...> _Td;
private:
_Fd __f_;
_Td __bound_args_;
typedef typename __make_tuple_indices<sizeof...(_BoundArgs)>::type __indices;
public:
template <class _Gp, class ..._BA,
class = typename enable_if
<
is_constructible<_Fd, _Gp>::value &&
!is_same<__libcpp_remove_reference_t<_Gp>,
__bind>::value
>::type>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit __bind(_Gp&& __f, _BA&& ...__bound_args)
: __f_(_VSTD::forward<_Gp>(__f)),
__bound_args_(_VSTD::forward<_BA>(__bound_args)...) {}
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type
operator()(_Args&& ...__args)
{
return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
tuple<_Args&&...>(_VSTD::forward<_Args>(__args)...));
}
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
operator()(_Args&& ...__args) const
{
return _VSTD::__apply_functor(__f_, __bound_args_, __indices(),
tuple<_Args&&...>(_VSTD::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,
class = typename enable_if
<
is_constructible<_Fd, _Gp>::value &&
!is_same<__libcpp_remove_reference_t<_Gp>,
__bind_r>::value
>::type>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
explicit __bind_r(_Gp&& __f, _BA&& ...__bound_args)
: base(_VSTD::forward<_Gp>(__f),
_VSTD::forward<_BA>(__bound_args)...) {}
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
is_convertible<typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type,
result_type>::value || is_void<_Rp>::value,
result_type
>::type
operator()(_Args&& ...__args)
{
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
return _Invoker::__call(static_cast<base&>(*this), _VSTD::forward<_Args>(__args)...);
}
template <class ..._Args>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename enable_if
<
is_convertible<typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type,
result_type>::value || is_void<_Rp>::value,
result_type
>::type
operator()(_Args&& ...__args) const
{
typedef __invoke_void_return_wrapper<_Rp> _Invoker;
return _Invoker::__call(static_cast<base const&>(*this), _VSTD::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>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bind<_Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
typedef __bind<_Fp, _BoundArgs...> type;
return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}
template<class _Rp, class _Fp, class ..._BoundArgs>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__bind_r<_Rp, _Fp, _BoundArgs...>
bind(_Fp&& __f, _BoundArgs&&... __bound_args)
{
typedef __bind_r<_Rp, _Fp, _BoundArgs...> type;
return type(_VSTD::forward<_Fp>(__f), _VSTD::forward<_BoundArgs>(__bound_args)...);
}
#endif // _LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_BIND_H

View file

@ -0,0 +1,64 @@
// -*- 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(_VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...)))
-> decltype( _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::forward<_BoundArgs>(__bound_args))...))
{ return _VSTD::invoke(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)..., _VSTD::get<_Ip>(_VSTD::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, class = enable_if_t<
_And<
is_constructible<decay_t<_Fn>, _Fn>,
is_move_constructible<decay_t<_Fn>>,
is_constructible<decay_t<_Args>, _Args>...,
is_move_constructible<decay_t<_Args>>...
>::value
>>
_LIBCPP_HIDE_FROM_ABI
constexpr auto __bind_back(_Fn&& __f, _Args&&... __args)
noexcept(noexcept(__bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...))))
-> decltype( __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)))
{ return __bind_back_t<decay_t<_Fn>, tuple<decay_t<_Args>...>>(_VSTD::forward<_Fn>(__f), _VSTD::forward_as_tuple(_VSTD::forward<_Args>(__args)...)); }
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_BIND_BACK_H

View file

@ -0,0 +1,62 @@
// -*- 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_move_constructible.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(_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))
-> decltype( _VSTD::invoke(_VSTD::forward<_Args>(__args)...))
{ return _VSTD::invoke(_VSTD::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, class = enable_if_t<
_And<
is_constructible<decay_t<_Fn>, _Fn>,
is_move_constructible<decay_t<_Fn>>,
is_constructible<decay_t<_Args>, _Args>...,
is_move_constructible<decay_t<_Args>>...
>::value
>>
_LIBCPP_HIDE_FROM_ABI
constexpr auto bind_front(_Fn&& __f, _Args&&... __args) {
return __bind_front_t<decay_t<_Fn>, decay_t<_Args>...>(_VSTD::forward<_Fn>(__f), _VSTD::forward<_Args>(__args)...);
}
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_BIND_FRONT_H

View file

@ -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_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_TEMPLATE_VIS _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_INLINE_VISIBILITY binder1st(const __Operation& __x,
const typename __Operation::first_argument_type __y)
: op(__x), value(__y) {}
_LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
(typename __Operation::second_argument_type& __x) const
{return op(value, __x);}
_LIBCPP_INLINE_VISIBILITY 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_INLINE_VISIBILITY
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

View file

@ -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_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_TEMPLATE_VIS _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_INLINE_VISIBILITY
binder2nd(const __Operation& __x, const typename __Operation::second_argument_type __y)
: op(__x), value(__y) {}
_LIBCPP_INLINE_VISIBILITY typename __Operation::result_type operator()
( typename __Operation::first_argument_type& __x) const
{return op(__x, value);}
_LIBCPP_INLINE_VISIBILITY 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_INLINE_VISIBILITY
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

View file

@ -0,0 +1,316 @@
//===----------------------------------------------------------------------===//
//
// 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
#include <__algorithm/fill_n.h>
#include <__config>
#include <__functional/hash.h>
#include <__functional/operations.h>
#include <__iterator/distance.h>
#include <__iterator/iterator_traits.h>
#include <__memory/shared_ptr.h>
#include <__type_traits/make_unsigned.h>
#include <__utility/pair.h>
#include <array>
#include <unordered_map>
#include <vector>
#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 _LIBCPP_TEMPLATE_VIS 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 = _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_uncvref<typename iterator_traits<_RandomAccessIterator1>::value_type,
typename iterator_traits<_RandomAccessIterator2>::value_type>::value,
"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;
vector<difference_type> __scratch(__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 _LIBCPP_TEMPLATE_VIS 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 = _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_uncvref<typename std::iterator_traits<_RandomAccessIterator1>::value_type,
typename std::iterator_traits<_RandomAccessIterator2>::value_type>::value,
"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

View file

@ -0,0 +1,52 @@
// -*- 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(_VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...))))
-> decltype( _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::forward<_Args>(__args)...)))
{ return _VSTD::invoke(_VSTD::forward<_Fn1>(__f1), _VSTD::invoke(_VSTD::forward<_Fn2>(__f2), _VSTD::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>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2))))
-> decltype( __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)))
{ return __compose_t<decay_t<_Fn1>, decay_t<_Fn2>>(_VSTD::forward<_Fn1>(__f1), _VSTD::forward<_Fn2>(__f2)); }
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_COMPOSE_H

View file

@ -0,0 +1,57 @@
// -*- 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 _LIBCPP_TEMPLATE_VIS default_searcher {
public:
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
default_searcher(_ForwardIterator __f, _ForwardIterator __l,
_BinaryPredicate __p = _BinaryPredicate())
: __first_(__f), __last_(__l), __pred_(__p) {}
template <typename _ForwardIterator2>
_LIBCPP_INLINE_VISIBILITY _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

1226
third_party/libcxx/__functional/function.h vendored Normal file

File diff suppressed because it is too large Load diff

687
third_party/libcxx/__functional/hash.h vendored Normal file
View file

@ -0,0 +1,687 @@
//===----------------------------------------------------------------------===//
//
// 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 <__functional/invoke.h>
#include <__functional/unary_function.h>
#include <__fwd/hash.h>
#include <__tuple/sfinae_helpers.h>
#include <__type_traits/is_copy_constructible.h>
#include <__type_traits/is_default_constructible.h>
#include <__type_traits/is_enum.h>
#include <__type_traits/is_move_constructible.h>
#include <__type_traits/underlying_type.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <__utility/pair.h>
#include <__utility/swap.h>
#include <cstddef>
#include <cstdint>
#include <cstring>
#include <limits>
#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;
_VSTD::memcpy(&__r, __p, sizeof(__r));
return __r;
}
// 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);
_LIBCPP_FALLTHROUGH();
case 2:
__h ^= static_cast<_Size>(__data[1] << 8);
_LIBCPP_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));
pair<_Size, _Size> __v = __weak_hash_len_32_with_seeds(__s + __len - 64, __len, __z);
pair<_Size, _Size> __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));
_VSTD::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 pair<_Size, _Size> __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);
return pair<_Size, _Size>(__a + __z, __b + __c);
}
// 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 pair<_Size, _Size> __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;
}
};
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 __murmur2_or_cityhash<size_t>()(&__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 __murmur2_or_cityhash<size_t>()(&__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 __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
}
};
struct _PairT {
size_t first;
size_t second;
};
_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 _LIBCPP_TEMPLATE_VIS 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 __murmur2_or_cityhash<size_t>()(&__u, sizeof(__u));
}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<bool>
: public __unary_function<bool, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(bool __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char>
: public __unary_function<char, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<signed char>
: public __unary_function<signed char, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(signed char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned char>
: public __unary_function<unsigned char, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(unsigned char __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
#ifndef _LIBCPP_HAS_NO_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char8_t>
: public __unary_function<char8_t, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(char8_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
#endif // !_LIBCPP_HAS_NO_CHAR8_T
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char16_t>
: public __unary_function<char16_t, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(char16_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<char32_t>
: public __unary_function<char32_t, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(char32_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
#ifndef _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
struct _LIBCPP_TEMPLATE_VIS hash<wchar_t>
: public __unary_function<wchar_t, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(wchar_t __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
#endif // _LIBCPP_HAS_NO_WIDE_CHARACTERS
template <>
struct _LIBCPP_TEMPLATE_VIS hash<short>
: public __unary_function<short, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned short>
: public __unary_function<unsigned short, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(unsigned short __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<int>
: public __unary_function<int, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned int>
: public __unary_function<unsigned int, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(unsigned int __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<long>
: public __unary_function<long, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long>
: public __unary_function<unsigned long, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(unsigned long __v) const _NOEXCEPT {return static_cast<size_t>(__v);}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<long long>
: public __scalar_hash<long long>
{
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<unsigned long long>
: public __scalar_hash<unsigned long long>
{
};
#ifndef _LIBCPP_HAS_NO_INT128
template <>
struct _LIBCPP_TEMPLATE_VIS hash<__int128_t>
: public __scalar_hash<__int128_t>
{
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<__uint128_t>
: public __scalar_hash<__uint128_t>
{
};
#endif
template <>
struct _LIBCPP_TEMPLATE_VIS hash<float>
: public __scalar_hash<float>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(float __v) const _NOEXCEPT
{
// -0.0 and 0.0 should return same hash
if (__v == 0.0f)
return 0;
return __scalar_hash<float>::operator()(__v);
}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<double>
: public __scalar_hash<double>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(double __v) const _NOEXCEPT
{
// -0.0 and 0.0 should return same hash
if (__v == 0.0)
return 0;
return __scalar_hash<double>::operator()(__v);
}
};
template <>
struct _LIBCPP_TEMPLATE_VIS hash<long double>
: public __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, bool = is_enum<_Tp>::value>
struct _LIBCPP_TEMPLATE_VIS __enum_hash
: public __unary_function<_Tp, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(_Tp __v) const _NOEXCEPT
{
typedef typename underlying_type<_Tp>::type type;
return hash<type>()(static_cast<type>(__v));
}
};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS __enum_hash<_Tp, false> {
__enum_hash() = delete;
__enum_hash(__enum_hash const&) = delete;
__enum_hash& operator=(__enum_hash const&) = delete;
};
template <class _Tp>
struct _LIBCPP_TEMPLATE_VIS hash : public __enum_hash<_Tp>
{
};
#if _LIBCPP_STD_VER >= 17
template <>
struct _LIBCPP_TEMPLATE_VIS hash<nullptr_t>
: public __unary_function<nullptr_t, size_t>
{
_LIBCPP_HIDE_FROM_ABI
size_t operator()(nullptr_t) const _NOEXCEPT {
return 662607004ull;
}
};
#endif
#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 &&
__invokable_r<size_t, _Hash, _Key const&>::value
>;
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
>;
#if _LIBCPP_STD_VER >= 17
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,
typename enable_if<__all<__has_enabled_hash<_Keys>::value...>::value>::type
>;
#else
template <class _Type, class ...>
using __enable_hash_helper _LIBCPP_NODEBUG = _Type;
#endif
#endif // !_LIBCPP_CXX03_LANG
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_HASH_H

View file

@ -0,0 +1,57 @@
// -*- 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 <__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>
_LIBCPP_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 {};
#if _LIBCPP_STD_VER >= 20
struct identity {
template<class _Tp>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr _Tp&& operator()(_Tp&& __t) const noexcept
{
return _VSTD::forward<_Tp>(__t);
}
using is_transparent = void;
};
template <>
struct __is_identity<identity> : true_type {};
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_IDENTITY_H

View file

@ -0,0 +1,56 @@
// -*- 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 <__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 _VSTD::__invoke(_VSTD::forward<_Fn>(__f), _VSTD::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

View file

@ -0,0 +1,36 @@
// -*- 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/integral_constant.h>
#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 _Tp, class, class = void>
struct __is_transparent : false_type {};
template <class _Tp, class _Up>
struct __is_transparent<_Tp, _Up, __void_t<typename _Tp::is_transparent> >
: true_type {};
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_IS_TRANSPARENT

View file

@ -0,0 +1,58 @@
// -*- 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/invoke.h>
#include <__functional/weak_result_type.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_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
__mem_fn(type __f) _NOEXCEPT : __f_(__f) {}
// invoke
template <class... _ArgTypes>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __invoke_return<type, _ArgTypes...>::type
operator() (_ArgTypes&&... __args) const {
return std::__invoke(__f_, std::forward<_ArgTypes>(__args)...);
}
};
template<class _Rp, class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _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

View file

@ -0,0 +1,173 @@
// -*- 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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_t
: public __unary_function<_Tp*, _Sp>
{
_Sp (_Tp::*__p_)();
public:
_LIBCPP_INLINE_VISIBILITY explicit mem_fun_t(_Sp (_Tp::*__p)())
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p) const
{return (__p->*__p_)();}
};
template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_t
: public __binary_function<_Tp*, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap);
public:
_LIBCPP_INLINE_VISIBILITY explicit mem_fun1_t(_Sp (_Tp::*__p)(_Ap))
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp* __p, _Ap __x) const
{return (__p->*__p_)(__x);}
};
template<class _Sp, class _Tp>
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
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_INLINE_VISIBILITY
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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun_ref_t
: public __unary_function<_Tp, _Sp>
{
_Sp (_Tp::*__p_)();
public:
_LIBCPP_INLINE_VISIBILITY explicit mem_fun_ref_t(_Sp (_Tp::*__p)())
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p) const
{return (__p.*__p_)();}
};
template<class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 mem_fun1_ref_t
: public __binary_function<_Tp, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap);
public:
_LIBCPP_INLINE_VISIBILITY explicit mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap))
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(_Tp& __p, _Ap __x) const
{return (__p.*__p_)(__x);}
};
template<class _Sp, class _Tp>
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
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_INLINE_VISIBILITY
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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_t
: public __unary_function<const _Tp*, _Sp>
{
_Sp (_Tp::*__p_)() const;
public:
_LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_t(_Sp (_Tp::*__p)() const)
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p) const
{return (__p->*__p_)();}
};
template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_t
: public __binary_function<const _Tp*, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap) const;
public:
_LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_t(_Sp (_Tp::*__p)(_Ap) const)
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp* __p, _Ap __x) const
{return (__p->*__p_)(__x);}
};
template <class _Sp, class _Tp>
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
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_INLINE_VISIBILITY
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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun_ref_t
: public __unary_function<_Tp, _Sp>
{
_Sp (_Tp::*__p_)() const;
public:
_LIBCPP_INLINE_VISIBILITY explicit const_mem_fun_ref_t(_Sp (_Tp::*__p)() const)
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p) const
{return (__p.*__p_)();}
};
template <class _Sp, class _Tp, class _Ap>
class _LIBCPP_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 const_mem_fun1_ref_t
: public __binary_function<_Tp, _Ap, _Sp>
{
_Sp (_Tp::*__p_)(_Ap) const;
public:
_LIBCPP_INLINE_VISIBILITY explicit const_mem_fun1_ref_t(_Sp (_Tp::*__p)(_Ap) const)
: __p_(__p) {}
_LIBCPP_INLINE_VISIBILITY _Sp operator()(const _Tp& __p, _Ap __x) const
{return (__p.*__p_)(__x);}
};
template <class _Sp, class _Tp>
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
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_INLINE_VISIBILITY
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

View file

@ -0,0 +1,57 @@
// -*- 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_move_constructible.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(!_VSTD::invoke(_VSTD::forward<_Args>(__args)...)))
-> decltype( !_VSTD::invoke(_VSTD::forward<_Args>(__args)...))
{ return !_VSTD::invoke(_VSTD::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>>(_VSTD::forward<_Fn>(__f));
}
#endif // _LIBCPP_STD_VER >= 17
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_NOT_FN_H

View file

@ -0,0 +1,590 @@
// -*- 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 <__type_traits/integral_constant.h>
#include <__type_traits/predicate_traits.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 _LIBCPP_TEMPLATE_VIS plus
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x, const _Tp& __y) const
{return __x + __y;}
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(plus);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS plus<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) + _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS minus
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_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 _LIBCPP_TEMPLATE_VIS minus<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) - _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS multiplies
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_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 _LIBCPP_TEMPLATE_VIS multiplies<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) * _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS divides
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_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 _LIBCPP_TEMPLATE_VIS divides<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) / _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS modulus
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_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 _LIBCPP_TEMPLATE_VIS modulus<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) % _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS negate
: __unary_function<_Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return -__x;}
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(negate);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS negate<void>
{
template <class _Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
noexcept(noexcept(- _VSTD::forward<_Tp>(__x)))
-> decltype( - _VSTD::forward<_Tp>(__x))
{ return - _VSTD::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 _LIBCPP_TEMPLATE_VIS bit_and
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_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 _LIBCPP_TEMPLATE_VIS bit_and<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) & _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
struct _LIBCPP_TEMPLATE_VIS bit_not
: __unary_function<_Tp, _Tp>
{
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_Tp operator()(const _Tp& __x) const
{return ~__x;}
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(bit_not);
template <>
struct _LIBCPP_TEMPLATE_VIS bit_not<void>
{
template <class _Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
noexcept(noexcept(~_VSTD::forward<_Tp>(__x)))
-> decltype( ~_VSTD::forward<_Tp>(__x))
{ return ~_VSTD::forward<_Tp>(__x); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_or
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_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 _LIBCPP_TEMPLATE_VIS bit_or<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) | _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS bit_xor
: __binary_function<_Tp, _Tp, _Tp>
{
typedef _Tp __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
_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 _LIBCPP_TEMPLATE_VIS bit_xor<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) ^ _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) ^ _VSTD::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 _LIBCPP_TEMPLATE_VIS equal_to
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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 _LIBCPP_TEMPLATE_VIS equal_to<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) == _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
template <class _Tp>
struct __is_trivial_equality_predicate<equal_to<_Tp>, _Tp, _Tp> : true_type {};
#if _LIBCPP_STD_VER >= 14
template <class _Tp>
struct __is_trivial_equality_predicate<equal_to<>, _Tp, _Tp> : true_type {};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS not_equal_to
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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 _LIBCPP_TEMPLATE_VIS not_equal_to<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) != _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS less
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x < __y;}
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(less);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS less<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) < _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS less_equal
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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 _LIBCPP_TEMPLATE_VIS less_equal<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) <= _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS greater_equal
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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 _LIBCPP_TEMPLATE_VIS greater_equal<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) >= _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS greater
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x, const _Tp& __y) const
{return __x > __y;}
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(greater);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS greater<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) > _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
// Logical operations
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_and
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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 _LIBCPP_TEMPLATE_VIS logical_and<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) && _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_not
: __unary_function<_Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
bool operator()(const _Tp& __x) const
{return !__x;}
};
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(logical_not);
#if _LIBCPP_STD_VER >= 14
template <>
struct _LIBCPP_TEMPLATE_VIS logical_not<void>
{
template <class _Tp>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_Tp&& __x) const
noexcept(noexcept(!_VSTD::forward<_Tp>(__x)))
-> decltype( !_VSTD::forward<_Tp>(__x))
{ return !_VSTD::forward<_Tp>(__x); }
typedef void is_transparent;
};
#endif
#if _LIBCPP_STD_VER >= 14
template <class _Tp = void>
#else
template <class _Tp>
#endif
struct _LIBCPP_TEMPLATE_VIS logical_or
: __binary_function<_Tp, _Tp, bool>
{
typedef bool __result_type; // used by valarray
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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 _LIBCPP_TEMPLATE_VIS logical_or<void>
{
template <class _T1, class _T2>
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
auto operator()(_T1&& __t, _T2&& __u) const
noexcept(noexcept(_VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u)))
-> decltype( _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u))
{ return _VSTD::forward<_T1>(__t) || _VSTD::forward<_T2>(__u); }
typedef void is_transparent;
};
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_OPERATIONS_H

View file

@ -0,0 +1,93 @@
// -*- 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 <__utility/declval.h>
#include <__utility/forward.h>
#include <__utility/move.h>
#include <tuple>
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
# pragma GCC system_header
#endif
_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_(_VSTD::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()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
-> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
{ return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::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()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...)))
-> decltype( _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::forward<_Args>(__args)...))
{ return _Op()(_VSTD::get<_Idx>(__bound_args_)..., _VSTD::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()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
-> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
{ return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::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()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...)))
-> decltype( _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::forward<_Args>(__args)...))
{ return _Op()(_VSTD::get<_Idx>(_VSTD::move(__bound_args_))..., _VSTD::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 = __perfect_forward_impl<_Op, index_sequence_for<_Args...>, _Args...>;
#endif // _LIBCPP_STD_VER >= 17
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_PERFECT_FORWARD_H

View file

@ -0,0 +1,46 @@
// -*- 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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_binary_function
: public __binary_function<_Arg1, _Arg2, _Result>
{
_Result (*__f_)(_Arg1, _Arg2);
public:
_LIBCPP_INLINE_VISIBILITY explicit pointer_to_binary_function(_Result (*__f)(_Arg1, _Arg2))
: __f_(__f) {}
_LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg1 __x, _Arg2 __y) const
{return __f_(__x, __y);}
};
template <class _Arg1, class _Arg2, class _Result>
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
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

View file

@ -0,0 +1,46 @@
// -*- 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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX11 pointer_to_unary_function
: public __unary_function<_Arg, _Result>
{
_Result (*__f_)(_Arg);
public:
_LIBCPP_INLINE_VISIBILITY explicit pointer_to_unary_function(_Result (*__f)(_Arg))
: __f_(__f) {}
_LIBCPP_INLINE_VISIBILITY _Result operator()(_Arg __x) const
{return __f_(__x);}
};
template <class _Arg, class _Result>
_LIBCPP_DEPRECATED_IN_CXX11 inline _LIBCPP_INLINE_VISIBILITY
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

View file

@ -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_RANGES_OPERATIONS_H
#define _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H
#include <__concepts/equality_comparable.h>
#include <__concepts/totally_ordered.h>
#include <__config>
#include <__type_traits/integral_constant.h>
#include <__type_traits/predicate_traits.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(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u)))) {
return _VSTD::forward<_Tp>(__t) == _VSTD::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(!(_VSTD::forward<_Tp>(__t) == _VSTD::forward<_Up>(__u))))) {
return !(_VSTD::forward<_Tp>(__t) == _VSTD::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(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u)))) {
return _VSTD::forward<_Tp>(__t) < _VSTD::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(!(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t))))) {
return !(_VSTD::forward<_Up>(__u) < _VSTD::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(_VSTD::forward<_Up>(__u) < _VSTD::forward<_Tp>(__t)))) {
return _VSTD::forward<_Up>(__u) < _VSTD::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(!(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u))))) {
return !(_VSTD::forward<_Tp>(__t) < _VSTD::forward<_Up>(__u));
}
using is_transparent = void;
};
} // namespace ranges
template <class _Lhs, class _Rhs>
struct __is_trivial_equality_predicate<ranges::equal_to, _Lhs, _Rhs> : true_type {};
#endif // _LIBCPP_STD_VER >= 20
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_RANGES_OPERATIONS_H

View file

@ -0,0 +1,111 @@
// -*- 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 <__config>
#include <__functional/invoke.h>
#include <__functional/weak_result_type.h>
#include <__memory/addressof.h>
#include <__type_traits/enable_if.h>
#include <__type_traits/remove_cvref.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 _LIBCPP_TEMPLATE_VIS 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;
public:
template <class _Up, class = __enable_if_t<!__is_same_uncvref<_Up, reference_wrapper>::value, decltype(__fun(std::declval<_Up>())) > >
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper(_Up&& __u) _NOEXCEPT_(noexcept(__fun(std::declval<_Up>()))) {
type& __f = static_cast<_Up&&>(__u);
__f_ = _VSTD::addressof(__f);
}
// access
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
operator type&() const _NOEXCEPT {return *__f_;}
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
type& get() const _NOEXCEPT {return *__f_;}
// invoke
template <class... _ArgTypes>
_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __invoke_of<type&, _ArgTypes...>::type
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 >= 17
template <class _Tp>
reference_wrapper(_Tp&) -> reference_wrapper<_Tp>;
#endif
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper<_Tp>
ref(_Tp& __t) _NOEXCEPT
{
return reference_wrapper<_Tp>(__t);
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper<_Tp>
ref(reference_wrapper<_Tp> __t) _NOEXCEPT
{
return __t;
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20
reference_wrapper<const _Tp>
cref(const _Tp& __t) _NOEXCEPT
{
return reference_wrapper<const _Tp>(__t);
}
template <class _Tp>
inline _LIBCPP_INLINE_VISIBILITY _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;
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_REFERENCE_WRAPPER_H

View file

@ -0,0 +1,51 @@
//===----------------------------------------------------------------------===//
//
// 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_TEMPLATE_VIS _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_DIAGNOSTIC_PUSH
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wdeprecated-declarations")
template <class _Arg, class _Result>
using __unary_function = unary_function<_Arg, _Result>;
_LIBCPP_DIAGNOSTIC_POP
#else
template <class _Arg, class _Result>
using __unary_function = __unary_function_keep_layout_base<_Arg, _Result>;
#endif
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_UNARY_FUNCTION_H

View file

@ -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_TEMPLATE_VIS _LIBCPP_DEPRECATED_IN_CXX17 unary_negate
: public __unary_function<typename _Predicate::argument_type, bool>
{
_Predicate __pred_;
public:
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
explicit unary_negate(const _Predicate& __pred)
: __pred_(__pred) {}
_LIBCPP_CONSTEXPR_SINCE_CXX14 _LIBCPP_INLINE_VISIBILITY
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_INLINE_VISIBILITY
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

View file

@ -0,0 +1,294 @@
// -*- 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/invoke.h>
#include <__functional/unary_function.h>
#include <__type_traits/integral_constant.h>
#include <__type_traits/is_same.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>
struct __has_result_type
{
private:
template <class _Up> static false_type __test(...);
template <class _Up> static true_type __test(typename _Up::result_type* = 0);
public:
static const bool value = decltype(__test<_Tp>(0))::value;
};
// __weak_result_type
template <class _Tp>
struct __derives_from_unary_function
{
private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _Ap, class _Rp>
static __unary_function<_Ap, _Rp>
__test(const volatile __unary_function<_Ap, _Rp>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
template <class _Tp>
struct __derives_from_binary_function
{
private:
struct __two {char __lx; char __lxx;};
static __two __test(...);
template <class _A1, class _A2, class _Rp>
static __binary_function<_A1, _A2, _Rp>
__test(const volatile __binary_function<_A1, _A2, _Rp>*);
public:
static const bool value = !is_same<decltype(__test((_Tp*)0)), __two>::value;
typedef decltype(__test((_Tp*)0)) type;
};
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>
{
};
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<_Tp>::value>
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>
{
};
// 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
};
template <class _Tp, class ..._Args>
struct __invoke_return
{
typedef decltype(_VSTD::__invoke(std::declval<_Tp>(), std::declval<_Args>()...)) type;
};
_LIBCPP_END_NAMESPACE_STD
#endif // _LIBCPP___FUNCTIONAL_WEAK_RESULT_TYPE_H