Re: [hub] on the specialized iteration over elements
Alexander Grund via Boost <[email protected]>
| Newsgroups | gmane.comp.lib.boost.devel |
|---|---|
| Message-ID | <[email protected]> |
Am 17.04.26 um 03:27 schrieb Jean-Louis Leroy via Boost:
> It seems to me that 'visit' is useful and legal only in combination
> with 'operator++',
> 'operator--' and the likes of 'std::next', 'std::prev',
> 'std::advance', etc. For example:
>
> int main() {
> boost::container::hub<int> h {1, 3, 5, 7, 9};
> auto first = h.begin();
> auto middle = std::next(first, h.size() / 2);
> auto last = h.end();
> h.visit(first, middle, [](int i){
> std::print("{} ", i);
> });
> std::print(" | ");
> h.visit(middle, last, [](int i){
> std::print("{} ", i);
> });
> }
>
> (https://godbolt.org/z/1e5E413r8)
>
> Important use cases are divide-and-conquer algorithms and parallelization.
>
> >From here, two things.
>
> If 'visit' is faster than just "ranging over", it probably (?) means
> that we need
> 'hub::advance' etc as well.
>
> But then an integer displacement is always involved, be it 1 or -1.
> Doesn't it suggest
> that 'visit' should take offsets, not iterators? That would take care
> of Andrzej's
> concern. And there is no need for public 'advance' etc members.
You'd probably still want iterator support not (only) offsets as you
might want to process all elements until or after the element returned
by e.g. `std::find`
As for `advance`: That sounds like an ADL-enabled `next` similar to `swap`
_______________________________________________
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/A35YCT7CBVD6SFF5QIOEMYNGFUONROQ2/
smime.p7s
(application/pkcs7-signature, 4.7 KB) - not displayed