Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2004-11-12 16:44:37

"Neal D. Becker" <ndbecker2_at_[hidden]> wrote in message
| John Torjo wrote:

| > As you probably know, the library is around 1 year old. I've used it
| > heavily on some of my projects, and all I can say is that iteration
| > capability has helped me much.
| >
| If you write all your algorithms to a range interface instead of iterator
| interface, that's a big win when you really want ranges. When you have to
| manually iterate in a loop, it's a loss. Now you have to say:
| template<class in_cont, class out_cont>
| algorithm (in_cont const& in, out_cont & out) {
| typename boost::range_const_iterator<in_cont>::type i = boost::begin (in);
| typename boost::range_iterator<out_cont>::type o = boost::begin (out);
| for (; i != boost::end (in); ++i, ++o) ...
| In this case, I'd say it's a net loss.

Sorry, could you elaborate on what the loss is? Using a new iterable range
concept we can say

sub_range<const in_cont> r( in );
for( ; r; ++r ) { ... }

If your question is: "should algorithms be implemented in terms of iterators
or ranges?",
then answer is "iterators". However, it makes sense not to expose the iterator
interface once you
have added the range layer and the iterator interface might use iterable
ranges in its implementation.


Boost list run by bdawes at, gregod at, cpdaniel at, john at