2

The usage of constexpr is quite straightforward which is to make sure the code can be evaluated at the compile time itself.

But the latest features of C++ 20 which provides constinit and consteval are little bit confusing. Can someone provide the practical use case of constinit and consteval?

ashubhatt
  • 21
  • 2
  • 1
    Constinit can help to avoid the static initialization fiasco - it enforces that initalization happens at compile time rather at runtime. But to use constinit the type must have a constexpr constructor which is of course not the case for all types. – Bernd Jul 05 '20 at 10:08

0 Answers0