C++ Logo

std-proposals

Advanced search

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

From: Simon Schröder <dr.simon.schroeder_at_[hidden]>
Date: Fri, 10 Apr 2026 07:10:24 +0200
> On Apr 10, 2026, at 3:17 AM, Muneem via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> Again, why do flat maps exist, why don't we all optimize maps away if the compiler can figure out that the constant latency of a flat maps is actually gonna be faster.

Regular maps exist because the performance gap between memory and CPU used to be a lot less when they were invented. And there are probably a lot of different microprocessors where a regular map is still faster than a flat map.

Why don’t compilers optimize every map into a flat map? Because the compiler still does exactly what the programmer tells it to do. If the programmer decides he wants a regular map he will get one. I hope the compiler will always obey the programmer!

Received on 2026-04-10 05:10:37