Can somebody explain what is a borrowed_range?

the text reads


iterators of borrowed ranges can sill be used when the range itself no longer exists


???


A borrowed range is one whose iterator validity doesn't rely on the lifetime of the parent object. Passing a non-borrowed range to an algorithm as an rvalue means that it will return a ranges::dangling rather than an iterator. A borrowed range can be wrapped in a view object using views::all()

https://en.cppreference.com/w/cpp/ranges/borrowed_range
https://en.cppreference.com/w/cpp/ranges/dangling

Last edited on
Topic archived. No new replies allowed.