[hub] on the specialized iteration over elements

Andrzej Krzemienski via Boost <[email protected]>
Newsgroups gmane.comp.lib.boost.devel
Message-ID <CAOenAXhXd1zOYHx5=jO6PqieB-H+Wp8W3_LJHXbdMuZN4F_7cg@mail.gmail.com>
Hi Everyone,
Once again, thank you Joaquín for this contribution to the community.

This is not really a review, but I wanted to talk about this idea to
implement a specialized algorithm for iterating over the container elements
in the form of hub::visit.

First, should we draw from this a more general observation that iterators
are an abstraction with overhead, and other containers (deque?) would also
benefit from this inversion-of-control approach?

Second, I think that the most natural naming choice for this operation is
"for each", not "visit". It does practically the same thing as
`std::for_each`.

Third, the interface is rather unusual, and it allows one hub to iterate
over another hub's elements:

hub<T> h, g;
h.visit(g.begin(), g.end(), fun);

https://godbolt.org/z/bbb765bb1

It looks like this function should be a free function rather than a member
function. And if there is a reason to make it a member function, at minimum
add a precondition that both the iterators should point inside the
container.

Regards,
&rzej;
_______________________________________________
Boost mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://lists.boost.org/mailman3/lists/boost.lists.boost.org/
Archived at: https://lists.boost.org/archives/list/[email protected]/message/YMUA57CPHWFYCVI3ZCNCP3VGCYXJC2PB/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.