Why must a std::ranges::filter_view object be non-const for querying its elements?

In order to provide the amortized constant time complexity required by range, filter_view::begin caches the result in *this. This modifies the internal state of *this and thus cannot be done in a const member function.

Leave a Comment

tech