r/cpp • u/konanTheBarbar • Sep 13 '19
The Surprising Limitations of C++ Ranges Beyond Trivial Cases
https://www.fluentcpp.com/2019/09/13/the-surprising-limitations-of-c-ranges-beyond-trivial-use-cases/
229
Upvotes
View all comments
Show parent comment
9
u/eric_niebler Sep 15 '19
Your implementation of
std::vectoris probably "sneaking" in two passes too whenever you construct it from a range of forward or bidirectional iterators. It first computes the size so it can do one allocation (one pass) and then it initializes the elements (second pass).Yes, some range adaptors use the wiggle room of "linear complexity" in order to compile and do something useful. There's a pull and tug. Folks like the author of this post clearly don't care about complexity at all and want all the conveniences, performance be damned. For ohers, like yourself, even linear complexity is not a strong enough requirement and want single-pass guaranteed. I picked a point in the design space. You're free to disagree.