C++ Logo


Advanced search

Subject: Re: [std-proposals] Aggregates are named tuples
From: Antony Polukhin (antoshkka_at_[hidden])
Date: 2020-03-08 01:42:49

On Sun, Mar 8, 2020, 02:07 Barry Revzin <barry.revzin_at_[hidden]> wrote:

> Check out P1858, coming to Evolution soon (there's going to be a new
> revision in this mailing, but not much has changed since R1). If that
> direction gets approved, then these library utilities would be somewhat
> obsolete but these specializations could be added on top of existing
> language features:
> template <typename T>
> concept pack_like = requires { sizeof...(T::[:]); };
> template <pack_like T> struct tuple_size<T> : integral_constant<size_t,
> sizeof...(T::[:])> { };
> template <size_t I, pack_like T> struct tuple_element<I, T> { using type =
> T::[I]; };
> template <size_t I, typename T>
> requires pack_like<remove_cvref_t<T>>
> decltype(auto) get(T&& t) {
> return forward<T>(t).[I];
> }

Thanks for the information!

P1858 gives the right and simple to use tools to implement "Aggregates are
named tuples". The latter simplifies adoption of P1858 ideas for users
(existing user code almost out-of-the-box starts to work with aggregates),
brings capabilities symmetry into the library.

I should probably sync with P1858 and make the std::get work in more cases.
I will also double check for standard library functions that could benefit
from upgraded std::get


STD-PROPOSALS list run by herb.sutter at gmail.com

Standard Proposals Archives on Google Groups