[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 19:53:20 PDT 2026
================
@@ -1362,79 +1362,56 @@ struct uses_allocator<tuple<_Tp...>, _Alloc> : true_type {};
# if _LIBCPP_STD_VER >= 17
# define _LIBCPP_NOEXCEPT_RETURN(...) \
- noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; }
+ noexcept(noexcept(__VA_ARGS__)) { return __VA_ARGS__; } \
+ static_assert(true)
-// The _LIBCPP_NOEXCEPT_RETURN macro breaks formatting.
-// clang-format off
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...>)
- _LIBCPP_NOEXCEPT_RETURN(std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...))
+inline
+ _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) __apply_tuple_impl(_Fn&& __f, _Tuple&& __t, index_sequence<_Id...>)
+ _LIBCPP_NOEXCEPT_RETURN(std::__invoke(std::forward<_Fn>(__f), std::get<_Id>(std::forward<_Tuple>(__t))...));
template <class _Fn, class _Tuple>
inline _LIBCPP_HIDE_FROM_ABI constexpr decltype(auto) apply(_Fn&& __f, _Tuple&& __t)
- _LIBCPP_NOEXCEPT_RETURN(std::__apply_tuple_impl(
- std::forward<_Fn>(__f),
- std::forward<_Tuple>(__t),
- make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>()))
+ _LIBCPP_NOEXCEPT_RETURN(std::__apply_tuple_impl(std::forward<_Fn>(__f),
+ std::forward<_Tuple>(__t),
+ make_index_sequence<tuple_size_v<remove_reference_t<_Tuple>>>()));
+# undef _LIBCPP_NOEXCEPT_RETURN
+
+template <class _Tp, class _Tuple, class _Seq = make_index_sequence<tuple_size_v<__remove_cvref_t<_Tuple>>>>
+inline constexpr bool __can_make_from_tuple_v = false;
-#if _LIBCPP_STD_VER >= 20
----------------
frederick-vs-ja wrote:
I discussed with @timsong-cpp before and he confirmed that the it wasn't intended to add constraints to `make_from_tuple` in LWG3528. But some other implementors didn't seem to think so. I think it's fine to propagate the `requires` and translate the constraints into C++17 constructs. [LWG3628](https://cplusplus.github.io/LWG/issue3628) is a bit related.
Maybe @yronglin just wanted to "do what the standard says" in C++20 and thus only translated the resolution in C++17 mode. I'm fine to only use C++17 constructs if this makes the implementation details clearer.
https://github.com/llvm/llvm-project/pull/215067
More information about the libcxx-commits
mailing list