diff --git a/libcxx/include/__functional/bind.h b/libcxx/include/__functional/bind.h index 328dc3bf3dab..cbe8660b821c 100644 --- a/libcxx/include/__functional/bind.h +++ b/libcxx/include/__functional/bind.h @@ -81,16 +81,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w return __t.get(); } -template -inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...> -__mu_expand(_Ti& __ti, tuple<_Uj...>& __uj, __index_sequence<_Indx...>) { - return __ti(std::forward<_Uj>(std::get<_Indx>(__uj))...); -} - template ::value, int> = 0> inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...> __mu(_Ti& __ti, tuple<_Uj...>& __uj) { - return std::__mu_expand(__ti, __uj, __make_index_sequence()); + return [&](__index_sequence<_Indices...>) -> __invoke_result_t<_Ti&, _Uj...> { + return __ti(std::forward<_Uj>(std::get<_Indices>(__uj))...); + }(__index_sequence_for<_Uj...>{}); } template @@ -217,10 +213,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 typename __bind_return<_Fd, _Td, tuple<_Args&&...> >::type operator()(_Args&&... __args) { return std::__apply_functor( - __f_, - __bound_args_, - __make_index_sequence(), - tuple<_Args&&...>(std::forward<_Args>(__args)...)); + __f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); } template @@ -228,10 +221,7 @@ public: typename __bind_return >::type operator()(_Args&&... __args) const { return std::__apply_functor( - __f_, - __bound_args_, - __make_index_sequence(), - tuple<_Args&&...>(std::forward<_Args>(__args)...)); + __f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...)); } }; diff --git a/libcxx/include/__mutex/once_flag.h b/libcxx/include/__mutex/once_flag.h index 808b1ea99cc0..ad15b2eb6df6 100644 --- a/libcxx/include/__mutex/once_flag.h +++ b/libcxx/include/__mutex/once_flag.h @@ -86,12 +86,10 @@ class __call_once_param { public: _LIBCPP_HIDE_FROM_ABI explicit __call_once_param(_Fp& __f) : __f_(__f) {} - _LIBCPP_HIDE_FROM_ABI void operator()() { __execute(__make_index_sequence::value>()); } - -private: - template - _LIBCPP_HIDE_FROM_ABI void __execute(__index_sequence<_Indices...>) { - std::__invoke(std::get<_Indices>(std::move(__f_))...); + _LIBCPP_HIDE_FROM_ABI void operator()() { + [&](__index_sequence<_Indices...>) -> void { + std::__invoke(std::get<_Indices>(std::move(__f_))...); + }(__make_index_sequence::value>()); } }; diff --git a/libcxx/include/__utility/integer_sequence.h b/libcxx/include/__utility/integer_sequence.h index 329826ae5eda..fe8773ab7316 100644 --- a/libcxx/include/__utility/integer_sequence.h +++ b/libcxx/include/__utility/integer_sequence.h @@ -42,6 +42,9 @@ using __index_sequence _LIBCPP_NODEBUG = __integer_sequence template using __make_index_sequence _LIBCPP_NODEBUG = __make_integer_sequence_impl<__integer_sequence, size_t, _SequenceSize>; +template +using __index_sequence_for _LIBCPP_NODEBUG = __make_index_sequence; + # if _LIBCPP_STD_VER >= 14 template diff --git a/libcxx/include/__utility/pair.h b/libcxx/include/__utility/pair.h index 61485123114b..d3914f655f2a 100644 --- a/libcxx/include/__utility/pair.h +++ b/libcxx/include/__utility/pair.h @@ -219,11 +219,7 @@ struct pair _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair(piecewise_construct_t __pc, tuple<_Args1...> __first_args, tuple<_Args2...> __second_args) noexcept( is_nothrow_constructible::value && is_nothrow_constructible::value) - : pair(__pc, - __first_args, - __second_args, - __make_index_sequence(), - __make_index_sequence()) {} + : pair(__pc, __first_args, __second_args, __index_sequence_for<_Args1...>(), __index_sequence_for<_Args2...>()) {} _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 pair& operator=(__conditional_t::value && is_copy_assignable::value, diff --git a/libcxx/include/future b/libcxx/include/future index 0877d66602e6..c249bc5e7938 100644 --- a/libcxx/include/future +++ b/libcxx/include/future @@ -1833,12 +1833,10 @@ public: _LIBCPP_HIDE_FROM_ABI __async_func(__async_func&& __f) : __f_(std::move(__f.__f_)) {} - _LIBCPP_HIDE_FROM_ABI _Rp operator()() { return __execute(__make_index_sequence()); } - -private: - template - _LIBCPP_HIDE_FROM_ABI _Rp __execute(__index_sequence<_Indices...>) { - return std::__invoke(std::move(std::get<_Indices>(__f_))...); + _LIBCPP_HIDE_FROM_ABI _Rp operator()() { + return [&](__index_sequence<_Indices...>) -> _Rp { + return std::__invoke(std::move(std::get<_Indices>(__f_))...); + }(__index_sequence_for<_Fp, _Args...>{}); } }; diff --git a/libcxx/include/scoped_allocator b/libcxx/include/scoped_allocator index 74effc547f3e..c72c470f0c54 100644 --- a/libcxx/include/scoped_allocator +++ b/libcxx/include/scoped_allocator @@ -434,10 +434,10 @@ public: piecewise_construct, __transform_tuple(typename __uses_alloc_ctor< _T1, inner_allocator_type&, _Args1... >::type(), std::move(__x), - __make_index_sequence()), + __index_sequence_for<_Args1...>()), __transform_tuple(typename __uses_alloc_ctor< _T2, inner_allocator_type&, _Args2... >::type(), std::move(__y), - __make_index_sequence())); + __index_sequence_for<_Args2...>())); } template diff --git a/libcxx/include/tuple b/libcxx/include/tuple index caa473012a7c..670b90fc7b3b 100644 --- a/libcxx/include/tuple +++ b/libcxx/include/tuple @@ -576,7 +576,7 @@ __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __type_list<_Up.. template class _LIBCPP_NO_SPECIALIZATIONS tuple { - typedef __tuple_impl<__make_index_sequence, _Tp...> _BaseT; + typedef __tuple_impl<__index_sequence_for<_Tp...>, _Tp...> _BaseT; _BaseT __base_; @@ -858,7 +858,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(_If<_And...>::value, tuple, __nat> const& __tuple) noexcept( _And...>::value) { - std::__memberwise_copy_assign(*this, __tuple, __make_index_sequence()); + std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>()); return *this; } @@ -866,15 +866,14 @@ public: _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const requires(_And...>::value) { - std::__memberwise_copy_assign(*this, __tuple, __make_index_sequence()); + std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>()); return *this; } _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple&& __tuple) const requires(_And...>::value) { - std::__memberwise_forward_assign( - *this, std::move(__tuple), __type_list<_Tp...>(), __make_index_sequence()); + std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Tp...>(), __index_sequence_for<_Tp...>()); return *this; } # endif // _LIBCPP_STD_VER >= 23 @@ -882,8 +881,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(_If<_And...>::value, tuple, __nat>&& __tuple) noexcept( _And...>::value) { - std::__memberwise_forward_assign( - *this, std::move(__tuple), __type_list<_Tp...>(), __make_index_sequence()); + std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Tp...>(), __index_sequence_for<_Tp...>()); return *this; } @@ -893,7 +891,7 @@ public: int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...> const& __tuple) noexcept(_And...>::value) { - std::__memberwise_copy_assign(*this, __tuple, __make_index_sequence()); + std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>()); return *this; } @@ -902,8 +900,7 @@ public: int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(tuple<_Up...>&& __tuple) noexcept(_And...>::value) { - std::__memberwise_forward_assign( - *this, std::move(__tuple), __type_list<_Up...>(), __make_index_sequence()); + std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Up...>(), __index_sequence_for<_Tp...>()); return *this; } @@ -912,7 +909,7 @@ public: enable_if_t< _And<_BoolConstant, is_assignable...>::value>* = nullptr> _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const tuple<_UTypes...>& __u) const { - std::__memberwise_copy_assign(*this, __u, __make_index_sequence()); + std::__memberwise_copy_assign(*this, __u, index_sequence_for<_Tp...>()); return *this; } @@ -920,7 +917,7 @@ public: enable_if_t< _And<_BoolConstant, is_assignable...>::value>* = nullptr> _LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple<_UTypes...>&& __u) const { - std::__memberwise_forward_assign(*this, __u, __type_list<_UTypes...>(), __make_index_sequence()); + std::__memberwise_forward_assign(*this, __u, __type_list<_UTypes...>(), index_sequence_for<_Tp...>()); return *this; } # endif // _LIBCPP_STD_VER >= 23 @@ -986,7 +983,7 @@ public: __enable_if_t< _And< _BoolConstant<_Np == sizeof...(_Tp)>, is_assignable<_Tp&, _Up const&>... >::value, int> = 0> _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np> const& __array) noexcept(_And...>::value) { - std::__memberwise_copy_assign(*this, __array, __make_index_sequence()); + std::__memberwise_copy_assign(*this, __array, __index_sequence_for<_Tp...>()); return *this; } @@ -998,7 +995,7 @@ public: _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple& operator=(array<_Up, _Np>&& __array) noexcept(_And...>::value) { std::__memberwise_forward_assign( - *this, std::move(__array), __type_list<_If...>(), __make_index_sequence()); + *this, std::move(__array), __type_list<_If...>(), __index_sequence_for<_Tp...>()); return *this; }