If I have range (pair of 2 iterators) is there a way to write \"for each\" loop for that uses range, not a raw array or container.
Something like this:
What std::equal_range
returns is simply a std::pair. The standard doesn't cover any method to iterate over such things.
What you may want to read is Alexandrescu's "Iterators must go" presentation. Here is the video. An excellent read on a more elegant way to iterate containers using Ranges.
Ranges are implemented in his Loki library.