diff options
Diffstat (limited to 'contrib/llvm-project/libcxx/include/__functional/bind.h')
| -rw-r--r-- | contrib/llvm-project/libcxx/include/__functional/bind.h | 75 |
1 files changed, 36 insertions, 39 deletions
diff --git a/contrib/llvm-project/libcxx/include/__functional/bind.h b/contrib/llvm-project/libcxx/include/__functional/bind.h index 297e4e5103a3..398cb3dc3480 100644 --- a/contrib/llvm-project/libcxx/include/__functional/bind.h +++ b/contrib/llvm-project/libcxx/include/__functional/bind.h @@ -13,9 +13,11 @@ #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> -#include <type_traits> #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) # pragma GCC system_header @@ -30,9 +32,9 @@ struct is_bind_expression : _If< is_bind_expression<__remove_cvref_t<_Tp> > > {}; -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr size_t is_bind_expression_v = is_bind_expression<_Tp>::value; +inline constexpr bool is_bind_expression_v = is_bind_expression<_Tp>::value; #endif template<class _Tp> @@ -42,9 +44,9 @@ struct is_placeholder : _If< is_placeholder<__remove_cvref_t<_Tp> > > {}; -#if _LIBCPP_STD_VER > 14 +#if _LIBCPP_STD_VER >= 17 template <class _Tp> -inline constexpr size_t is_placeholder_v = is_placeholder<_Tp>::value; +inline constexpr int is_placeholder_v = is_placeholder<_Tp>::value; #endif namespace placeholders @@ -52,29 +54,24 @@ namespace placeholders template <int _Np> struct __ph {}; -#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) -_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; -#else -/* inline */ constexpr __ph<1> _1{}; -/* inline */ constexpr __ph<2> _2{}; -/* inline */ constexpr __ph<3> _3{}; -/* inline */ constexpr __ph<4> _4{}; -/* inline */ constexpr __ph<5> _5{}; -/* inline */ constexpr __ph<6> _6{}; -/* inline */ constexpr __ph<7> _7{}; -/* inline */ constexpr __ph<8> _8{}; -/* inline */ constexpr __ph<9> _9{}; -/* inline */ constexpr __ph<10> _10{}; -#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY) +// C++17 recommends that we implement placeholders as `inline constexpr`, but allows +// implementing them as `extern <implementation-defined>`. Libc++ implements them as +// `extern const` in all standard modes to avoid an ABI break in C++03: making them +// `inline constexpr` requires removing their definition in the shared library to +// avoid ODR violations, which is an ABI break. +// +// In practice, since placeholders are empty, `extern const` is almost impossible +// to distinguish from `inline constexpr` from a usage stand point. +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<1> _1; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<2> _2; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<3> _3; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<4> _4; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<5> _5; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<6> _6; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<7> _7; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<8> _8; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<9> _9; +_LIBCPP_EXPORTED_FROM_ABI extern const __ph<10> _10; } // namespace placeholders @@ -86,7 +83,7 @@ struct is_placeholder<placeholders::__ph<_Np> > #ifndef _LIBCPP_CXX03_LANG template <class _Tp, class _Uj> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_wrapper<_Tp> __t, _Uj&) { @@ -94,7 +91,7 @@ __mu(reference_wrapper<_Tp> __t, _Uj&) } template <class _Ti, class ..._Uj, size_t ..._Indx> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __invoke_of<_Ti&, _Uj...>::type __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) { @@ -102,7 +99,7 @@ __mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __tuple_indices<_Indx...>) } template <class _Ti, class ..._Uj> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __enable_if_t < is_bind_expression<_Ti>::value, @@ -124,7 +121,7 @@ struct __mu_return2<true, _Ti, _Uj> }; template <class _Ti, class _Uj> -inline _LIBCPP_INLINE_VISIBILITY +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if < 0 < is_placeholder<_Ti>::value, @@ -132,12 +129,12 @@ typename enable_if >::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)); + 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 +inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_SINCE_CXX20 typename enable_if < !is_bind_expression<_Ti>::value && @@ -255,7 +252,7 @@ struct __bind_return<_Fp, const tuple<_BoundArgs...>, _TupleUj, true> }; template <class _Fp, class _BoundArgs, size_t ..._Indx, class _Args> -inline _LIBCPP_INLINE_VISIBILITY +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) @@ -264,11 +261,11 @@ __apply_functor(_Fp& __f, _BoundArgs& __bound_args, __tuple_indices<_Indx...>, } template<class _Fp, class ..._BoundArgs> -class __bind : public __weak_result_type<typename decay<_Fp>::type> +class __bind : public __weak_result_type<__decay_t<_Fp> > { protected: - typedef typename decay<_Fp>::type _Fd; - typedef tuple<typename decay<_BoundArgs>::type...> _Td; + using _Fd = __decay_t<_Fp>; + typedef tuple<__decay_t<_BoundArgs>...> _Td; private: _Fd __f_; _Td __bound_args_; |
