Sujet : Re: constexpr keyword is unnecessary
De : Bonita.Montero (at) *nospam* gmail.com (Bonita Montero)
Groupes : comp.lang.cDate : 15. Oct 2024, 12:41:10
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <velkbv$1mkr0$1@raubtier-asyl.eternal-september.org>
References : 1 2 3 4 5 6 7 8 9 10 11
User-Agent : Mozilla Thunderbird
Am 15.10.2024 um 05:30 schrieb DFS:
On 10/13/2024 6:51 AM, Bonita Montero wrote:
Am 12.10.2024 um 23:37 schrieb Thiago Adams:
>
If you are afraid your constant is not constant expression put a static_assert. Then remove.
>
This is unnecessary work if you have constexpr.
>
(C++ is a TOTAL mess. const in C++ already could be used n constant expression)
>
C++ is five to ten times less work for the same problem.
How do you measure "work'?
In lines of code. Imagine you would specialize a container like
unordered_map by hand in C. That would be days of work. In C++
it's one line of code and you get nearly optimal performance.
Or just think about what an emplace_back on a vector of strings
all does; if the capacity isn't sufficient a doubled vector is
allocated (libstdc++, libc++), all objects are moved there and
a new item is emplaced at the end. That's one line of code, but
in C that's a half day's work.