C++ Logo

std-proposals

Advanced search

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

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 05 Apr 2026 16:51:44 -0700
On Sunday, 5 April 2026 10:49:34 Pacific Daylight Time Steve Weinrich via Std-
Proposals wrote:
> He seems to be fixated on a container of some type that returns references
> to different type of containers. For the life of me, I can't figure out why
> this would be needed or how to make it type-safe!

So far, all I've understood is that this is a new syntax for simplifying:
 a) the creation of a std::variant<references, ...>
 b) visitation

That is, if you had:
 std::vector<Foo>
 std::map<Foo, Bar>

You would implicitly declare a
 std::variant<std::vector<Foo> &, std::map<Foo, Bar> &>

populate it with either a runtime or compile time choice

and visit it, calling a function or more in it.

It would be up to the compiler to determine that every use of this type
compiles for every type in the variant.

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
  Principal Engineer - Intel Data Center - Platform & Sys. Eng.

Received on 2026-04-05 23:51:54