|
Boost : |
From: David Abrahams (dave_at_[hidden])
Date: 2007-11-09 10:22:39
on Fri Nov 09 2007, Thorsten Ottosen <nesotto-AT-cs.aau.dk> wrote:
> Dear all,
>
> As suggested by several people, I have started to rely on
> range_difference<T>::type in all places of the library.
>
> I have also updated the docs w.r.t new concepts and are working on
> polishing them.
>
> 1.35 will introduce a new function
>
> template< class T >
> BOOST_DEDUCED_TYPENAME range_difference<T>::type size( const T& r );
Really, you're returning the difference_type and not the size_type?
> that requires T to be a random access range. I also want to put a
> post-condition saying "result >= 0", but was a bit in doubt when I read
> the standards wording for std::distance():
>
> "template<class InputIterator>
> typename iterator_traits<InputIterator>::difference_type
> distance(InputIterator first, InputIterator last);
> 4 Effects: Returns the number of increments or decrements needed to get
> from first to last.
> 5 Requires: last shall be reachable from first."
>
> How can one ever use decrements to get from first to last?
When InputIterator is a random access iterator, last < first does not
violate the precondition.
-- Dave Abrahams Boost Consulting http://www.boost-consulting.com
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk