ericniebler / stl2

LaTeX and Markdown source for the Ranges TS/STL2 and associated proposals
88 stars 8 forks source link

views which apply functions in their iterator operations should require O(1) #585

Open CaseyCarter opened 6 years ago

CaseyCarter commented 6 years ago

E.g., filter_view, transform_view. If the functions these views invoke in their iterator operations aren't required to have O(1) complexity, then the view's iterators necessarily can't provide the O(1) complexity guarantee. See https://stackoverflow.com/questions/53341822/ for an example.

JohelEGP commented 4 years ago

Shouldn't filter_view's requirement go further? In order to achieve the amortized O(1) requirement of the increment of its iterator, the predicate shouldn't look at salient properties of the values being iterated, or filter_view should always be an input range. Consider v | filter(is_even), which currently satisfies bidirectional_range; it doesn't provide amortized O(1) iteration, so it doesn't model it (nor forward_range).

JohelEGP commented 1 year ago

Shouldn't filter_view's requirement go further?

The same can apply to istream_view.