Boost logo

Boost Users :

Subject: [Boost-users] Overloading boost::for_each()
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-08-28 16:58:34

There are several container types (such as typical deque implementations,
if you have access to their internals) that can have for_each()
implemented for them in a way that is faster than using iterators and a
generic for_each() function. Is there a way to take advantage of that in
Boost.Range, such as by overloading boost::for_each()? Is there some kind
of Iterable concept that doesn't require actual iterators or allows them
to be slow? Would it be worthwhile to add one? Are there any other
techniques that would be useful instead, such as always calling for_each()
unqualified in my code and using ADL to find custom versions (like is done
for swap)? I am not interested in making Boost.Range algorithms use this
new concept, but there are places in my own code that could use for_each()
rather than explicit loops if that was faster. Thank you for any answers
or advice.

-- Jeremiah Willcock

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at