Boost logo

Boost :

Subject: Re: [boost] difference_type size()?
From: Olaf van der Spek (ml_at_[hidden])
Date: 2011-10-19 04:46:09

On Wed, Oct 19, 2011 at 1:45 AM, Rhys Ulerich <rhys.ulerich_at_[hidden]> wrote:
>> iterator_range returns a signed size. Is this correct?
>> IMO it should return size_t.
>> boost\range\iterator_range_core.hpp:
>> difference_type size() const
>> {
>>        return m_End - m_Begin;
>> }
> Random thought: It seems like advance_begin and advance_end could be
> used to create a strictly negative size.  Returning difference_type
> allows this to be detected while a size_type does not.

Sounds like a very weak reason. Especially since:
If an instance of iterator_range is constructed by a client with two
iterators, the client must ensure that the two iterators delimit a
valid closed-open range [begin,end).

If that's the rationale, it'd be better to add is_valid() or so.


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