On Wed, 15 Jul 2026, Tomasz Kaminski wrote:

Would algorithms like fill/fold/transform benefit from for_each primitive?
I.e. something that iterates over all elements and invokes the provided
callback.
Because such operation can be implemented with a lot less code for views
like
filter/transform or also join.

We are getting away from the topic of segmented iterators, but I would be in favor of implementing several algorithms in terms of some basic ones (like for_each), and making those customization points (i.e. not just specializing them for std:: objects, but letting users specialize them). There are a number of objects where implementing for_each is both simpler and more efficient than iterators, and many uses of iterators don't need the full power of iterators. (ideally we could implement some iterators in terms of coroutines calling for_each, but that doesn't work so well, sadly)

See also https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105308

--
Marc Glisse

Reply via email to