Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions libcxx/include/__functional/bind.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,16 +81,12 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Tp& __mu(reference_w
return __t.get();
}

template <class _Ti, class... _Uj, size_t... _Indx>
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 <class _Ti, class... _Uj, __enable_if_t<is_bind_expression<_Ti>::value, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 __invoke_result_t<_Ti&, _Uj...>
__mu(_Ti& __ti, tuple<_Uj...>& __uj) {
return std::__mu_expand(__ti, __uj, __make_index_sequence<sizeof...(_Uj)>());
return [&]<size_t... _Indices>(__index_sequence<_Indices...>) {
return __ti(std::forward<_Uj>(std::get<_Indices>(__uj))...);
}(__index_sequence_for<_Uj...>{});
}

template <bool _IsPh, class _Ti, class _Uj>
Expand Down Expand Up @@ -217,21 +213,15 @@ class __bind : public __weak_result_type<__decay_t<_Fp> > {
_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<sizeof...(_BoundArgs)>(),
tuple<_Args&&...>(std::forward<_Args>(__args)...));
__f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
}

template <class... _Args>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20
typename __bind_return<const _Fd, const _Td, tuple<_Args&&...> >::type
operator()(_Args&&... __args) const {
return std::__apply_functor(
__f_,
__bound_args_,
__make_index_sequence<sizeof...(_BoundArgs)>(),
tuple<_Args&&...>(std::forward<_Args>(__args)...));
__f_, __bound_args_, __index_sequence_for<_BoundArgs...>(), tuple<_Args&&...>(std::forward<_Args>(__args)...));
}
};

Expand Down
10 changes: 4 additions & 6 deletions libcxx/include/__mutex/once_flag.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<tuple_size<_Fp>::value>()); }

private:
template <size_t... _Indices>
_LIBCPP_HIDE_FROM_ABI void __execute(__index_sequence<_Indices...>) {
std::__invoke(std::get<_Indices>(std::move(__f_))...);
_LIBCPP_HIDE_FROM_ABI void operator()() {
[&]<size_t... _Indices>(__index_sequence<_Indices...>) {
std::__invoke(std::get<_Indices>(std::move(__f_))...);
}(__make_index_sequence<tuple_size<_Fp>::value>());
}
};

Expand Down
3 changes: 3 additions & 0 deletions libcxx/include/__utility/integer_sequence.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ using __index_sequence _LIBCPP_NODEBUG = __integer_sequence<size_t, _Indices...>
template <size_t _SequenceSize>
using __make_index_sequence _LIBCPP_NODEBUG = __make_integer_sequence_impl<__integer_sequence, size_t, _SequenceSize>;

template <class... _Args>
using __index_sequence_for _LIBCPP_NODEBUG = __make_index_sequence<sizeof...(_Args)>;

# if _LIBCPP_STD_VER >= 14

template <class _Tp, _Tp... _Indices>
Expand Down
6 changes: 1 addition & 5 deletions libcxx/include/__utility/pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,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<first_type, _Args1...>::value && is_nothrow_constructible<second_type, _Args2...>::value)
: pair(__pc,
__first_args,
__second_args,
__make_index_sequence<sizeof...(_Args1)>(),
__make_index_sequence<sizeof...(_Args2)>()) {}
: 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<is_copy_assignable<first_type>::value && is_copy_assignable<second_type>::value,
Expand Down
10 changes: 4 additions & 6 deletions libcxx/include/future
Original file line number Diff line number Diff line change
Expand Up @@ -1836,12 +1836,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<sizeof...(_Args) + 1>()); }

private:
template <size_t... _Indices>
_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 [&]<size_t... _Indices>(__index_sequence<_Indices>...) {
return std::__invoke(std::move(std::get<_Indices>(__f_))...);
}(__index_sequence_for<_Fp, _Args...>{});
}
};

Expand Down
4 changes: 2 additions & 2 deletions libcxx/include/scoped_allocator
Original file line number Diff line number Diff line change
Expand Up @@ -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<sizeof...(_Args1)>()),
__index_sequence_for<_Args1...>()),
__transform_tuple(typename __uses_alloc_ctor< _T2, inner_allocator_type&, _Args2... >::type(),
std::move(__y),
__make_index_sequence<sizeof...(_Args2)>()));
__index_sequence_for<_Args2...>()));
}

template <class _T1, class _T2>
Expand Down
25 changes: 11 additions & 14 deletions libcxx/include/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ __memberwise_forward_assign(_Dest& __dest, _Source&& __source, __type_list<_Up..

template <class... _Tp>
class _LIBCPP_NO_SPECIALIZATIONS tuple {
typedef __tuple_impl<__make_index_sequence<sizeof...(_Tp)>, _Tp...> _BaseT;
typedef __tuple_impl<__index_sequence_for<_Tp...>, _Tp...> _BaseT;

_BaseT __base_;

Expand Down Expand Up @@ -860,32 +860,30 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
operator=(_If<_And<is_copy_assignable<_Tp>...>::value, tuple, __nat> const& __tuple) noexcept(
_And<is_nothrow_copy_assignable<_Tp>...>::value) {
std::__memberwise_copy_assign(*this, __tuple, __make_index_sequence<sizeof...(_Tp)>());
std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>());
return *this;
}

# if _LIBCPP_STD_VER >= 23
_LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(tuple const& __tuple) const
requires(_And<is_copy_assignable<const _Tp>...>::value)
{
std::__memberwise_copy_assign(*this, __tuple, __make_index_sequence<sizeof...(_Tp)>());
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<is_assignable<const _Tp&, _Tp>...>::value)
{
std::__memberwise_forward_assign(
*this, std::move(__tuple), __type_list<_Tp...>(), __make_index_sequence<sizeof...(_Tp)>());
std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Tp...>(), __index_sequence_for<_Tp...>());
return *this;
}
# endif // _LIBCPP_STD_VER >= 23

_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
operator=(_If<_And<is_move_assignable<_Tp>...>::value, tuple, __nat>&& __tuple) noexcept(
_And<is_nothrow_move_assignable<_Tp>...>::value) {
std::__memberwise_forward_assign(
*this, std::move(__tuple), __type_list<_Tp...>(), __make_index_sequence<sizeof...(_Tp)>());
std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Tp...>(), __index_sequence_for<_Tp...>());
return *this;
}

Expand All @@ -895,7 +893,7 @@ public:
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
operator=(tuple<_Up...> const& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
std::__memberwise_copy_assign(*this, __tuple, __make_index_sequence<sizeof...(_Tp)>());
std::__memberwise_copy_assign(*this, __tuple, __index_sequence_for<_Tp...>());
return *this;
}

Expand All @@ -904,8 +902,7 @@ public:
int> = 0>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
operator=(tuple<_Up...>&& __tuple) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
std::__memberwise_forward_assign(
*this, std::move(__tuple), __type_list<_Up...>(), __make_index_sequence<sizeof...(_Tp)>());
std::__memberwise_forward_assign(*this, std::move(__tuple), __type_list<_Up...>(), __index_sequence_for<_Tp...>());
return *this;
}

Expand All @@ -914,15 +911,15 @@ public:
enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
is_assignable<const _Tp&, const _UTypes&>...>::value>* = nullptr>
_LIBCPP_HIDE_FROM_ABI constexpr const tuple& operator=(const tuple<_UTypes...>& __u) const {
std::__memberwise_copy_assign(*this, __u, __make_index_sequence<sizeof...(_Tp)>());
std::__memberwise_copy_assign(*this, __u, index_sequence_for<_Tp...>());
return *this;
}

template <class... _UTypes,
enable_if_t< _And<_BoolConstant<sizeof...(_Tp) == sizeof...(_UTypes)>,
is_assignable<const _Tp&, _UTypes>...>::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<sizeof...(_Tp)>());
std::__memberwise_forward_assign(*this, __u, __type_list<_UTypes...>(), index_sequence_for<_Tp...>());
return *this;
}
# endif // _LIBCPP_STD_VER >= 23
Expand Down Expand Up @@ -988,7 +985,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<is_nothrow_assignable<_Tp&, _Up const&>...>::value) {
std::__memberwise_copy_assign(*this, __array, __make_index_sequence<sizeof...(_Tp)>());
std::__memberwise_copy_assign(*this, __array, __index_sequence_for<_Tp...>());
return *this;
}

Expand All @@ -1000,7 +997,7 @@ public:
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 tuple&
operator=(array<_Up, _Np>&& __array) noexcept(_And<is_nothrow_assignable<_Tp&, _Up>...>::value) {
std::__memberwise_forward_assign(
*this, std::move(__array), __type_list<_If<true, _Up, _Tp>...>(), __make_index_sequence<sizeof...(_Tp)>());
*this, std::move(__array), __type_list<_If<true, _Up, _Tp>...>(), __index_sequence_for<_Tp...>());
return *this;
}

Expand Down
Loading