Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<tuple>: LWG-3528 make_from_tuple can perform (the equivalent of) a C-style cast #2160

Merged
merged 2 commits into from
Sep 2, 2021
Merged
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
6 changes: 4 additions & 2 deletions stl/inc/tuple
Original file line number Diff line number Diff line change
Expand Up @@ -981,8 +981,10 @@ constexpr decltype(auto) apply(_Callable&& _Obj, _Tuple&& _Tpl) { // invoke _Obj
}

template <class _Ty, class _Tuple, size_t... _Indices>
constexpr _Ty _Make_from_tuple_impl(
_Tuple&& _Tpl, index_sequence<_Indices...>) { // construct _Ty from the elements of _Tpl
constexpr _Ty _Make_from_tuple_impl(_Tuple&& _Tpl, index_sequence<_Indices...>) {
// construct _Ty from the elements of _Tpl
static_assert(is_constructible_v<_Ty, decltype(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl)))...>,
"the target type must be constructible from the fields of the argument tuple (N4892 [tuple.apply]/2).");
return _Ty(_STD get<_Indices>(_STD forward<_Tuple>(_Tpl))...);
}

Expand Down