|
Boost : |
Subject: Re: [boost] difference_type size()?
From: Olaf van der Spek (ml_at_[hidden])
Date: 2011-10-21 11:10:15
On Fri, Oct 21, 2011 at 4:57 PM, pavel <paul.cpprules_at_[hidden]> wrote:
> 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
Isn't that just an implementation detail?
The interface should not be driven by implementation details.
> 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
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
-- Olaf
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk