Daily bit(e) of C++ | std::views::take, std::views::take_while
Daily bit(e) of C++ #195, The C++20 views of the leading elements of a range: std::views::take, std::views::take_while.
The C++20 std::views::take and std::views::take_while produce views of the leading elements of the adapted range.
Additionally, std::views::take is optimized for random access ranges and will not introduce any overhead for std::span, std::string_view, std::views::iota, std::views::repeat and std::ranges::subrange (if it models random_access and sized).