-
Book Overview & Buying
-
Table Of Contents
Data Structures and Algorithms with the C++ STL
By :
With the introduction of the constexpr specifier in C++11 and its enhancements in subsequent versions, compile-time computation in C++ has taken a significant leap. The ability for functions and constructors to operate at compile time via constexpr enables optimization and assurance of specific attributes before the code runs. This section examines the integration of constexpr within the STL, particularly concerning algorithms and containers.
In its infancy during C++11, constexpr was primarily for straightforward computations. The C++14 extension broadened its scope, embracing loops and conditional structures. By C++20, there was further augmentation allowing for constexpr allocations via std::allocator. This made containers such as std::vector and std::string usable with constexpr, though with certain restrictions.
Originally, constexpr wasn’t widely...