Šimon Tóth’s Post

View profile for Šimon Tóth

C++ Educational Content Creator | 20 years of Software Engineering experience distilled into digestible daily posts

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). Compiler Explorer link: https://lnkd.in/emMCi2T3 #cpp #cplusplus #coding #programming #dailybiteofcpp

  • text
Landon Viator

University of Louisiana at…2K followers

2y

Oh my god, wait, this example you just gave literally fixes something I do every day!

Landon Viator

University of Louisiana at…2K followers

2y

I feel like I need to just start reading the standard library a bit every day to see what’s there. There might be a bunch of things I write myself and know about it.

Vishal Oza

none985 followers

2y

ranges and views are to C++20 like what algorithms where to C++98-C++11. We do not have to worry about the iterator pairs The more we learn about ranges and views the better C++ programmers we become.

Like
Reply

Thanks, these concise but to the point snippets are very helpful.

Like
Reply
See more comments

To view or add a comment, sign in

Explore content categories