Boost logo

Boost :

Subject: Re: [boost] difference_type size()?
From: pavel (paul.cpprules_at_[hidden])
Date: 2011-10-20 14:15:00


 Olaf wrote on Wednesday, October 19, 2011 at 21:03:25:
> On Wed, Oct 19, 2011 at 7:01 PM, pavel <paul.cpprules_at_[hidden]> wrote:
>>  Olaf wrote on Wednesday, October 19, 2011 at 1:30:03:
>>> Hi,
>>
>>> iterator_range returns a signed size. Is this correct?
>>> IMO it should return size_t.
>>
>> given two arbitrary valid random access iterators (from one range) let
>> you know the distance between them
>>
>> it is either positive or negative (or 0) dependent on the order of the
>> given iterators
>>
>> i'd say difference type should be ptrdiff_t in the general case

> We're not talking about difference_type.
> We're talking about the return type of size().

> Olaf

> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost

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

-- 
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