C++ Logo

std-proposals

Advanced search

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

From: Muneem <itfllow123_at_[hidden]>
Date: Sat, 4 Apr 2026 22:09:58 +0500
I am really thankful for your feedback ❤️❤️❤️❤️❤️
The thing is just that I want a complete fix, just like rvalue expressions
were to copying overhead. I thank you all a lot for giving me feedbacks to
narrow my proposal to being smaller and smaller. I really really hope that
we continue this tomorrow so please keep on sending me feedback/critique
and asking questions ❤️❤️❤️❤️❤️❤️. I think I finally maybe able to sleep(
after 10 hours of not being able to sleep because my left eye hurting ).
This day was fun because I got to talk to all of you and you are all
awesome. ❤️
Regards, Muneem


On Sat, 4 Apr 2026, 10:01 pm Marcin Jaczewski via Std-Proposals, <
std-proposals_at_[hidden]> wrote:

> sob., 4 kwi 2026 o 17:36 Thiago Macieira via Std-Proposals
> <std-proposals_at_[hidden]> napisał(a):
> >
> > On Saturday, 4 April 2026 03:04:27 Pacific Daylight Time Marcin
> Jaczewski via
> > Std-Proposals wrote:
> > > Like:
> > > ```
> > > void foo(int i)
> > > {
> > > switch(i) { ... }
> > > }
> > > void bar(int i)
> > > {
> > > for (auto& x: data) for(i);
> > > }
> > > ```
> > >
> > > change into:
> > >
> > > ```
> > > template<int i>
> > > void foo()
> > > {
> > > //code based on i, like `std::get<i>`
> > > }
> > > void bar(int i)
> > > {
> > > switch (i){
> > > case 0:
> > > for (auto& x: data)
> > > {
> > > foo<0>();
> > > }
> > > break;
> > > case 1:
> > > for (auto& x: data)
> > > {
> > > foo<1>();
> > > }
> > > break;
> > > //etc.
> > > }
> > > }
> > > ```
> >
> > Compilers already do that on their own.
> >
> > They may not be doing that all the time, though. So if you do need to
> enforce
> > this, implementing manually may be necessary.
> >
> > Do we need a new language construct for this? Especially in the presence
> of
> > template for?
> >
>
> Yes, a compiler can do this but needs to have every function inlined,
> I was thinking in a more general case
> when a programmer creates code that is in different TU or code is too
> complex for the compiler to digest.
>
> And the only thing I would propose is that `template for` can create
> `case` but this side tangent to this whole thread.
> My post was an overall search for a more proper solution to Muneem's
> problem that uses currently available tools or needs only small tweaks
> to langage.
>
> > --
> > Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
> > Principal Engineer - Intel Data Center - Platform & Sys. Eng.
> > --
> > Std-Proposals mailing list
> > Std-Proposals_at_[hidden]
> > https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
> --
> Std-Proposals mailing list
> Std-Proposals_at_[hidden]
> https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals
>

Received on 2026-04-04 17:10:15