C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Make std::make_from_tuple SFINAE friendly

From: Yrong <yronglin777_at_[hidden]>
Date: Mon, 22 Apr 2024 01:53:23 +0800
Hi,

I've a proposal
https://yronglin.github.io/wg21-papers/MakeFromTupleSFINAEFriendly.pdf

Feel free to left comments.

Thanks,
Yrong

Yrong <yronglin777_at_[hidden]> 于2024年4月2日周二 00:54写道:

> Hi,
>
> I've updated the wording, but I'm not sure should we keep the
> requires-clause on "make-from-tuple-impl"?
>
> *Wording:*
>
> This wording is relative to N4971 <https://wg21.link/N4971>.
>
> 1.
>
> Edit 22.4.6 [tuple.apply] <https://wg21.link/tuple.apply> as indicated:
>
> template<class T, tuple-like Tuple>
> constexpr T make_from_tuple(Tuple&& t);
>
> *-3- Let I be the pack 0, 1, ..., (tuple_size_v<remove_reference_t<Tuple>> - 1).*
>
> -4- Constraints:
>
> - is_constructible_v<T, decltype(get<I>(declval<Tuple>()))...> is true, and
>
> - if tuple_size_v<remove_reference_t<Tuple>> is 1, then reference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))> is false.
>
> *-3- Mandates: If tuple_size_v<remove_reference_t<Tuple>> is 1,
> then reference_constructs_from_temporary_v<T, decltype(get<0>(declval<Tuple>()))> is false.
> <https://eel.is/c++draft/tuple.apply#3.sentence-1>*
>
> *-4-*-5- *Effects:* Given the exposition-only function:
>
> [...]
>
> template<class T, tuple-like Tuple, size_t... I> requires is_constructible_v<T, decltype(get<I>(declval<Tuple>()))...>
> constexpr T *make-from-tuple-impl*(Tuple&& t, index_sequence<I...>) { // exposition only
> return T(get<I>(std::forward<Tuple>(t))...);
> }
>
> [...]
>
> Equivalent to:
>
> return *make-from-tuple-impl*<T>(
> std::forward<Tuple>(t),
> make_index_sequence<tuple_size_v<remove_reference_t<Tuple>>>{});
>
> [*Note 1:* The type of T must be supplied as an explicit template
> parameter, as it cannot be deduced from the argument list. — *end note*]
>
>
>

Received on 2024-04-21 17:53:38