Hello,
There's a an idea to make std::get, std::tuple_element and std::tuple_size work with aggregates that have no base classes. In that way we get effective std::tuple replacement with elements also accessible via a readable name.
Any comments and suggestions are wellcome.
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
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];
}
Although not exactly like that since this would be infinitely recursive for types like std::tuple today, but something like that.
Barry