Topic: Question on input iterators


Author: jhyslop@ieee.org (Jim Hyslop)
Date: Sat, 14 Aug 2004 21:16:15 GMT
Raw View
Azumanga wrote:

> A small question with regards input iterators.
[...]
> I assume therefore lines 1,2 and 3 are undefined and anything could
> happen (including a crash).
> Line 4 is defined
Yep.

(although to be honest fairly pointless)
As is 1.

--
Jim



---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: dave@boost-consulting.com (David Abrahams)
Date: Sun, 15 Aug 2004 05:21:19 GMT
Raw View
azumanga@bubblescope.net (Azumanga) writes:

> Hello. I have already posted this in comp.lang.c++, but I was advised
> that posting it in here may lead to a better response. I apologise for
> posting in two different groups, but I would like clarification on
> this point.
>
> A small question with regards input iterators.
>
> Table 72 of the standard says with regards ++r on an input iterator r:
>
> "any copies of the previous value of r are no longer required to be
> dereferencable or in the domain of =="
>
> Consider therefore the following code segment, where r is a currently
> valid dereferencable input iterator.
>
> a=r;
> ++r;
>
> if(a==a) {} // Line 1
> if(a==r) {} // Line 2
> ++a; // Line 3
> a=r; // Line 4
> I assume therefore lines 1,2 and 3 are undefined and anything could
> happen (including a crash).

Yes.

> Line 4 is defined

True

--
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: llewelly.at@xmission.dot.com (llewelly)
Date: Mon, 16 Aug 2004 16:41:02 GMT
Raw View
jhyslop@ieee.org (Jim Hyslop) writes:

> Azumanga wrote:
>
>> A small question with regards input iterators.
> [...]
>> I assume therefore lines 1,2 and 3 are undefined and anything could
>> happen (including a crash).
>> Line 4 is defined
> Yep.
>
> (although to be honest fairly pointless)
> As is 1.

How is 'if(a==a) {}' defined if a is no longer required to be in the
    domain of == ?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: jhyslop@ieee.org (Jim Hyslop)
Date: Wed, 18 Aug 2004 05:31:55 GMT
Raw View
llewelly wrote:

> jhyslop@ieee.org (Jim Hyslop) writes:
>>Azumanga wrote:
>>>(although to be honest fairly pointless)
>>As is 1.
>
>
> How is 'if(a==a) {}' defined if a is no longer required to be in the
>     domain of == ?

Sorry, I meant that the statement 'if (a==a)' is fairly pointless,
regardless of its semantic or syntactic correctness.

--
Jim


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: azumanga@bubblescope.net (Azumanga)
Date: Fri, 13 Aug 2004 13:55:17 GMT
Raw View
Hello. I have already posted this in comp.lang.c++, but I was advised
that posting it in here may lead to a better response. I apologise for
posting in two different groups, but I would like clarification on this
point.

A small question with regards input iterators.

Table 72 of the standard says with regards ++r on an input iterator r:

"any copies of the previous value of r are no longer required to be
dereferencable or in the domain of =="

Consider therefore the following code segment, where r is a currently
valid dereferencable input iterator.

a=r;
++r;

if(a==a) {} // Line 1
if(a==r) {} // Line 2
++a; // Line 3
a=r; // Line 4
I assume therefore lines 1,2 and 3 are undefined and anything could
happen (including a crash).
Line 4 is defined (although to be honest fairly pointless)

Thank you

Azumanga

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]