Exploring Compile-time Sizes for Range Adaptors in C++
The article discusses the concept of compile-time sizes for range adaptors in C++. The author begins by introducing the static constexpr std::integral_constant idiom to specify the size of a range at compile-time. They explain that while the standard library supports this feature, the think-cell ranges library already natively supports compile-time sizes. The author explores two ways to query the size: a size function that returns an integer and a constexpr_size variable template that determines the compile-time size. They also discuss the implementation of tc::constexpr_size and how it can be used with range adaptors. The article highlights the importance of transparently forwarding the size properties of the underlying range when using range adaptors. The author concludes by suggesting a solution for conditionally returning std::integral_constant from the size() function. This article is relevant for developers who want to understand how to work with compile-time sizes and range adaptors in C++.