|
Boost : |
From: Damien Fisher (damien_at_[hidden])
Date: 2002-05-17 10:05:13
On Fri, 17 May 2002, Daniel Frey wrote:
> How about:
>
> template< typename Iterator >
> bool is_distance( Iterator first,
> call_traits< Iterator >::param_type last, // Add
> const?
> int distance ) // Should have a default?
> {
> while( distance >= 0 && first != last ) {
> ++first;
> --distance;
> }
>
> return distance == 0;
> }
Sure, that's basically it. Only things to add:
1.) don't use int for distance, use difference_type from
iterator_traits
2.) specialization for random access iterators
3.) docs, test cases, etc.
4.) it might also be nice to have an advance_n to parallel std::advance.
This isn't a complicated piece of code, so I don't imagine it will take
me long to finish it. However, I'm not going to bother if it isn't
going to get included in boost...can someone clarify whether this needs
a formal review or not? It seems like an overly trivial piece of code
to necessitate one.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk