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
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
Deutsch (Online)
English (Online)
Rainer Grimm
Cottbuser Weg 20
72108 Rottenburg
Tel.: +49 7472 917441
Mobil: +49 152 31965939
Mail: schulung@ModernesCpp.de
www.ModernesCpp.de (Deutsch)
www.ModernesCpp.net (English)