C++ Logo

std-discussion

Advanced search

Re: std::apply and adl get

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Wed, 29 Sep 2021 15:26:19 +0200
Il 29/09/21 13:50, Jordi Vilar via Std-Discussion ha scritto:
> But right now, I would find
> std::apply more versatile and powerful if the restriction to use
> `std::get` instead `get` by ADL was removed.

The point I was trying to make is that this would be just a stopgap
measure. The next immediate complaint is going to be that you're not
finding non-static get() instead of ADL get(), and so on.

What I'd really like to have here is reflection^Wsome
language/(meta)-library tooling that allows to programmatically do what
a structured binding syntax does.

In other words, have some standard-provided functionality to:
* have a trait that tells me if a type T is destructurable;
* given a destructurable type T, know its "tuple size";
* given T, know the type of each of its I-th destructured members;
* given a value of type T, get the value of its I-th destructured member;

These are necessarily generalizations of the currently available
std::tuple_size / std::tuple_element / ADL-get, as they're not used in
all the possible cases allowed by a structured binding syntax. (Of
course, a solution could be to make those calls "just work" on
destructurable types.)

Then, once you have all of this, it would makes sense to port all the
discussed tuple-related functionality to it (incl. std::apply).

My 2 c,

-- 
Giuseppe D'Angelo | giuseppe.dangelo_at_[hidden] | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts

Received on 2021-09-29 08:26:27