C++23: From imperative loops to declarative ranges
Posted by alefore@reddit | programming | View on Reddit | 2 comments
Posted by alefore@reddit | programming | View on Reddit | 2 comments
razialx@reddit
I’m a bit long in the tooth at this point but I didn’t find any of the ranges examples to be more readable. But that’s me.
SuperV1234@reddit
In a vacuum, I would agree with you. But for a simple loop like the one you have shown, using ranges is absolutely overkill.
The logic is obvious even with the first approach (just missing a
reserve
). The ranges version will have a non-negligible impact on compilation times and debug performance.I like ranges, but -- just like
auto
-- they shouldn't be used everywhere. Use them sparingly where their benefits outweigh their cons.