Subject: Re: [boost] [Range] Confusing result of iterator_range::size()
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2011-11-03 06:00:58
Den 03-11-2011 10:13, Jeffrey Lee Hellrung, Jr. skrev:
> On Thu, Nov 3, 2011 at 1:54 AM, Thorsten Ottosen<
> thorsten.ottosen_at_[hidden]> wrote:
>> Well, its /not/ unlikely that it will break code.
> Well, okay, sure, *some* code is going to break. Do you have actual code
> (i.e., not contrived examples) that you predict would fail?
Its not contrieved at all. Did you not read the rest of my answer?
Even changing it to unsigned won't remove all compile errors that
motivated a change.
> Given that this has come up twice in the last month, I think it's worth
> discussing the fallout from such a change. If one were to redesign
> boost::iterator_range all over again, is there an argument *against* making
> size() return an unsigned type?
Well, it used to return an unsigned type. It was then changed because
iterator traits have no notion of unsigned types.
And , AFAICR, there was a discussion about this on the list, convincing
me that using difference_type was the right thing to do.
It also makes it easier to write an assertion, if someone constructed
an iterator range incorrectly.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk