The New Static constexpr std::integral_constant Idiom in C++
The article discusses a new idiom in C++ called the static constexpr std::integral_constant. The author explains that while the size of std::array<T, N> is known at compile-time, it only provides a regular .size() member function. This can be problematic when writing generic code that expects a compile-time sized range. The author suggests that it would be more convenient if std::array::size were a static member function instead. They propose using the ::size() syntax to get the size of an array without breaking existing code. Additionally, the author introduces the idea of using std::integral_constant as the result of type-based metaprogramming. They demonstrate how std::array::size can be used to obtain a std::integral_constant that represents the size. The article concludes by mentioning that the C++ committee's library evolution group is considering adopting this idiom for all new standard library components with constant sizes. Overall, this new idiom provides a more convenient and efficient way to work with compile-time sized ranges in C++.