Boost logo

Boost :

Subject: Re: [boost] difference_type size()?
From: pavel (paul.cpprules_at_[hidden])
Date: 2011-10-21 10:57:35


 Olaf wrote on Friday, October 21, 2011 at 0:34:29:
> On Thu, Oct 20, 2011 at 8:15 PM, pavel <paul.cpprules_at_[hidden]> wrote:
>> sorry, i misread the initial message
>>
>> if the definition of size is how many times one need to ++begin to
>> reach end then it's clearly must be something like size_t
>>
>> but if size is (end - begin) for random access iterators it well may
>> be a signed integer, e.g. ptrdiff_t

> Why?
> Are you trying to imply end - begin can be negative for a valid range?

its natural for me that the result of (rand_iter - rand_iter) is
returned without type conversion, which is a signed integer

so, to convert or not to convert to unsigned is then the user's
responsibility

but if you state that in any way size() is the number of (++begin)'s
to reach end, then regardless of the implementation it may return
size_t (involving type conversion in case of random access iterators)

it's mere a "politics" question, a matter of definition of size()

-- 
Pavel
P.S.
if you notice a grammar mistake or weird phrasing in my message
please point it out

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