Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2003-11-03 07:32:36


On Mon, Nov 03, 2003 at 11:02:59PM +1100, Thorsten Ottosen wrote:
> "Pavol Droba" <droba_at_[hidden]> wrote in message
> news:20031103111711.GD12977_at_lenin.felcer.sk...
> > On Mon, Nov 03, 2003 at 09:09:34PM +1100, Thorsten Ottosen wrote:
> >
> > [snip]
> >

[snip]
 
> Every member function should preserve the invariant to ensure safe usage of
> the class. That's why I want to know the invariant of
> iterator_range. AFAICT, it is
>
> 1. begin() <= end()
> 2 empty() implies begin() == end()
>
> this is a reasonable invariant (and suggest that the class is sound), but
> this it not cool
>
> iterartor_range< ... > r = find( ... );
> ...
> r.reverse();
> ...
> sort( r.begin(), r.end() );
>
> which suggest reverse() should not be part of the interface.
>
> Besides, I couldn't find one place were you call it in the string library.
>

I see no problem with removing 'reverse'. You are right, it is not used anymore,
and probably I just forgot to remove it.
 
> > I don't know about any reason why it should be a generic range. What
> > benefits
> > whould it bring?
> >
> > > > Adding additional functionality and meaning to the iterator_range will
> > > > break its original
> > > > purpose.
> > > >
> > > so far we don't know what the purpose is.
> > >
> > It's purpose is to encapsulate a pair of iterators delimiting a range in a
> > container.
> >
> in which case reverse() does not make sense because it causes the iterator
> not to delimit a range.
>
> Anyway, just as you said iterator_range was a more generic version of my
> miserable
> basic_string attempt, then range is more general than iterator_range. You
> made the string algorithms
> as generic as possible, but you don't think the range should be as generic
> as possible :-).

Sure, it is a kind of generalization. But what benefit would it bring to make
such a generalization?

How can a range of numbers (a.k.a interaval) be used by an algorithm?

iterator_range contains iterators, and due to nature of iterators it allows
to iterate (access) the elements in the range. I realy don't see anything,
that could such a generalization bring. Can you provide some examples where
it could be useful. A place where a range of iterators can be used in the
same way as a generic range (a numeric interval)...
 
Regards,

Pavol


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk