Boost logo

Boost Users :

Subject: Re: [Boost-users] A forward iterator need not be default-constructible
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2011-10-03 11:57:52


On Mon, 3 Oct 2011, Krzysztof ¯elechowski wrote:

> Dave Abrahams wrote:
>
>>
>> on Sun Oct 02 2011, Andrew Sutton <asutton.list-AT-gmail.com> wrote:
>>
>>> I would take that to mean that singularity is independent of type.
>>
>> Although many types have singular values with respect to certain
>> operations (NULL is singular with respect to pointer dereference),
>>
>> - Not every type has singular values
>> - Some types have multiple singular values
>> - In general, one type's singular values are distinct from another
>> type's singular values
>>
>> I don't know what you and Chris mean by "independent of type," but to me
>> this sounds like singularity is highly dependent on type.
>
> It means iterators of the same type can be singular but need not, whereas
> all (valid) iterators of the same type either must support random access
> operations or must not, depending on the type in question.
>
> Of course, the result of subtraction may be undefined, but it will not fail
> to compile. If you insist that random access iterators are things you can
> universally subtract, it will be a concept that applies to pairs, not to
> individual objects.

Another complicating issue is that an iterator is singular or non-singular
with respect to a particular container. For example, given the following
declarations:

int a[5], b[5];

and assuming a and b are contiguous in memory, &a[5] is a singular
iterator for the array a, while &b[0] is non-singular for the array b,
even though those two pointers will have exactly the same value and are
not distinguishable by C++ code.

-- Jeremiah Willcock


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net