Boost logo

Boost :

Subject: Re: [boost] [variant] Please vote for behavior
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2013-01-29 06:12:28


On Tue, Jan 29, 2013 at 10:56 AM, Rob Stewart <robertstewart_at_[hidden]>wrote:

> On Jan 28, 2013, at 5:12 PM, Joel de Guzman <djowel_at_[hidden]> wrote:
>
> > On 1/29/13 5:58 AM, Gottlob Frege wrote:
> >>>> How do I know if is it singular valued?
> >>>> >>
> >>> >
> >>> >How do you know if an iterator is singular valued? You can't. Same
> here.
> >>> >
> >> it == container.end()?
> >>
> >> Or am I confused?
> >
> > Nope. A singular valued iterator may not be compared. A singular valued
> iterator is not associated with any sequence. E.g default constructed
> iterator pointing to nowhere.
>
> Singular iterators are default constructed instances that represent a
> universal end iterator.

This is only true for some iterators. Generally, comparing to default
constructed iterators is UB; for example comparing to default initialized
pointers. It is generally not possible to discover a singular iterator.

HTH,

-- gpd


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