C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Member apply

From: Giuseppe D'Angelo <giuseppe.dangelo_at_[hidden]>
Date: Mon, 3 Jul 2023 17:52:56 +0200
On 03/07/2023 17:22, Jason McKesson via Std-Proposals wrote:
> I think the reasoning for `std::apply` being a non-member function is
> very different from that of `visit`. `std::visit`*only* works with
> `std::variant`, so it makes sense for it to be a member function. In
> contrast, `std::apply` works with any type conforming to the
> `std::tuple`-style of access.

To play devil's advocate, at the moment that's actually the same with
std::apply: it only works with "tuple-like" types, which is a closed set
of types:

https://eel.is/c++draft/tuple.like

so one could "legitimately" ask to add a member `apply` to all those
types. (And also... cat? make_from_this?)

I have no idea why the concept doesn't simply require the type to
implement the tuple protocol. P2141 is changing the definition of the
concept to that effect, but that paper is also doing much more.

My 2 c,
-- 
Giuseppe D'Angelo

Received on 2023-07-03 15:52:59