[libcxx-commits] [libcxx] [libc++] Simplify the implementation of std::make_from_tuple (PR #215067)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Aug 10 20:22:19 PDT 2026
================
@@ -1362,79 +1362,56 @@ struct uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
# if _LIBCPP_STD_VER >= 17
# define _LIBCPP_NOEXCEPT_RETURN(...) \
----------------
frederick-vs-ja wrote:
Now I think it's clearer to avoid this macro.
Maybe we can change the code as the following. Clang-format made me quite unhappy when formatting the definition of `apply`, so I'd like to manually format it.
```C++
template <class _Fn, class _Tuple, size_t... _Id>
inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto)
__apply_tuple_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Id...>) //
noexcept(noexcept(std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...))) {
return /*--------*/ std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...);
}
// clang-format off
template <class _Fn, class _Tuple>
inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& __t) noexcept(noexcept(
std::__apply_tuple_impl(std::forward<_Fn>(__f), std::forward<_Tuple>(__t),
make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>()))) {
return std::__apply_tuple_impl(std::forward<_Fn>(__f), std::forward<_Tuple>(__t),
make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>());
}
// clang-format on
```
https://github.com/llvm/llvm-project/pull/215067
More information about the libcxx-commits
mailing list