C++ Logo

std-proposals

Advanced search

Re: [std-proposals] Extension to runtime polymorphism proposed

From: Marcin Jaczewski <marcinjaczewski86_at_[hidden]>
Date: Sat, 4 Apr 2026 15:52:33 +0200
sob., 4 kwi 2026 o 15:33 Bjorn Reese via Std-Proposals
<std-proposals_at_[hidden]> napisaƂ(a):
>
> On 4/4/26 08:59, Sebastian Wittmeier via Std-Proposals wrote:
> > The problem seems to be
> >
> > {a, b, c}.select(k).op(...)
> >
> > - {a, b, c} is something like a std::variant - can be of different
> > types out of a provided list of types (closed set, not open set / std::any)
>
> It is a heterogeneous collection, so it is more like std::tuple.
>

Maybe a simple solution is `std::select` for tuple?
Like:

```
auto y = std::select([](auto& x) { return x.foo(); }, tuple, index);
```

Why change language if standard lib can provide required function?
It has all context and intend to create the most optimal code.

> > - there is a way to get which type to use or which type it is. Would
> > also work, if b and c is the same type with different operations, as
> > long as select can distinguish between b and c
> >
> > - the types neither have a common interface with the same method
> > signature / syntax (as can be used from a template), nor a common
> > ancestor or descendent in an inheritance hierarchy
> >
> > - certain operations should be called on those types. What exactly is
> > called can differ between the selected types
>
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals

Received on 2026-04-04 13:52:49