Boost logo

Boost :

From: Thorsten Ottosen (nesotto_at_[hidden])
Date: 2003-11-19 22:06:07


"John Torjo" <john.lists_at_[hidden]> wrote in message
news:3FBCFAE9.5060004_at_torjo.com...
>
> >>>>You can also manually set the beginning and end of a range:
> >>>>// ignore first and last 5 elements
> >>>>r.begin( v.begin() + 5);
> >>>>r.end( v.end() - 5);
[snip]
> > In the rare cases where it is needed, one can easily copy both
iterators.
> > What if the iterators are not random access? what if they are not
> > bidirectional?
>
> I don't see what this has to do with resetting begin() or end().
> Please explain.

well, if they are not random access, you can't do

r.set_begin( v.begin() + 5 );

if they are not bidirectional, you must do something like

r.set_end( std::advanece( r.begin(), size( r ) - 5 ) );

and it starts to get troublesome.

> Now, take a look at generated_range, which adapts a functor into a range.
> This is pretty cool, and I see lots of places where that can be used.

example:
rng::copy( generated(step(), gen_n(10)),
std::ostream_iterator<int>(std::cout," "));

how does this relate to the generator_iterator already part of boost? Or the
new iterators described in
http://anubis.dkuug.dk/jtc1/sc22/wg21/docs/papers/2003/n1530.html ?

It's not that I don't believe you, I just don't have too much time figuring
out how something can be used
and why is it better than something we already got. If you wrote a design
document
that explained why it was better than all known things on earth, it would be
much easier for me to see.

In the above code, I have a lot of unanswered questions, eg.

why can't I say 10 instead of gen_n( 10 ) ? What's the performance of this
compared to other implementations.
I'm not sure, but I think functional C++ has a lot of similar stuff.
What if I don't want the range [0,9] but [1,10] ?
How is it better than this stuff I once wrote:
http://www.cs.auc.dk/~nesotto/init/#Synopsis
I'm thinking about the enum stuff or n_genereted_by.

That is why I really need to see some docs. It will save both of us a lot of
time.

best regards

Thorsten


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