C++26: more constexpr in the core language
a year ago
- #C++26
- #constexpr
- #programming
- C++11 introduced constexpr, with limited functionality like no if/else or loops.
- C++14 expanded constexpr to include if/else and loops.
- C++17 added support for constexpr lambdas.
- C++20 allowed allocation and use of std::vector and std::string in constexpr.
- C++26 introduces constexpr cast from void* (P2738R1), enabling standard library functions like std::format to work at compile time.
- C++26 adds constexpr placement new (P2747R2), allowing more flexible initialization in constant expressions.
- C++26 supports constexpr structured bindings and references (P2686R5), with relaxed restrictions on storage duration.
- Future articles will cover constexpr exceptions and standard library updates.