C++ Logo

std-proposals

Advanced search

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

From: Andre Kostur <andre_at_[hidden]>
Date: Sat, 4 Apr 2026 04:39:01 +0000
On Sat, Apr 4, 2026 at 4:31 AM Muneem <itfllow123_at_[hidden]> wrote:
>
> Hi!
> Mr.Andre kustor asked a very good and welcomed question:
> If I were to write:
>
> auto & x = return_index_chosen(read_from_string<uint8_t>(string_to_read_from,
> pos));
>
> What is the type of x ? Particularly if string_to_read_from is a runtime value.
>
> The answer is the *********const reference type********* of the object at the index read by "read_from_string<uint8_t>(string_to_read_from,
> pos)" that of course can be modified after type casting const_cast. if the "const" is an issue then please propose something else, I really need to see if it's not perfect.

Why is const suddenly part of the discussion? Actually, don't answer
that: there's more important things to worry about before we need to
talk about that.

How does the compiler know if in the next line I may do
"x.capacity();"? Remember, read_from_string is getting me a runtime
value. How does the compiler know whether to accept my call to
capacity()?

Received on 2026-04-04 04:39:14