Date: Sun, 22 Nov 2020 16:41:20 +0100
I had the same issue. When I explain constinit, I put it into a bigger
picture
I talk about constness and explain the differences of: const, constexpr,
constinit, consteval, and is_constant_evaluted. In particular, I compare
the differences of const, constexpr and constinit when initializing a
variable. A nice use-case for constinit is it to solve the static
initialization fiasco.
Rainer
On 22/11/2020 16:07, Nicolai Josuttis via SG20 wrote:
> Starting to learn and document C++20, I just realized that
> the keyword "constinit" seems very confusing.
> Every naive programmer would assume it means "init a const",
> but it seems the const is simply wrong; it is the opposite.
> Or as Jonathan Müller wrote in a talk:
> constinit = constexpr - const
>
> Now I wonder how to teach that.
> Could somebody elaborate please why we have chosen this name
> and what is the best way to make this name plausible to ordinary
> programmers?
>
> Thanks
> Nico
>
picture
I talk about constness and explain the differences of: const, constexpr,
constinit, consteval, and is_constant_evaluted. In particular, I compare
the differences of const, constexpr and constinit when initializing a
variable. A nice use-case for constinit is it to solve the static
initialization fiasco.
Rainer
On 22/11/2020 16:07, Nicolai Josuttis via SG20 wrote:
> Starting to learn and document C++20, I just realized that
> the keyword "constinit" seems very confusing.
> Every naive programmer would assume it means "init a const",
> but it seems the const is simply wrong; it is the opposite.
> Or as Jonathan Müller wrote in a talk:
> constinit = constexpr - const
>
> Now I wonder how to teach that.
> Could somebody elaborate please why we have chosen this name
> and what is the best way to make this name plausible to ordinary
> programmers?
>
> Thanks
> Nico
>
-- Modernes C++ Deutsch (Online) * Embedded Programmierung mit modernem C++: <https://www.modernescpp.de/index.php/c/2-c/29-embedded-programmierung-mit-modernem-c20201029102414>26.01.2021 - 28.01.2021 (9:00 - 17:00 CEST), Termingarantie English (Online) * C++20 - A Deep Insight: <https://www.modernescpp.net/index.php/c/2-c/31-c-20>Feb. 1. 2021 - Feb. 3. 2021 (16:00 - 20:00 UTC) Rainer Grimm Cottbuser Weg 20 72108 Rottenburg Tel.: +49 7472 917441 Mobil: +49 152 31965939 Mail: schulung_at_[hidden] <schulung_at_[hidden]> www.ModernesCpp.de <www.ModernesCpp.de> (Deutsch) www.ModernesCpp.net <www.ModernesCpp.net> (English)
Received on 2020-11-22 09:41:25