incubator-stdcxx-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Travis Vitek (JIRA)" <>
Subject [jira] Commented: (STDCXX-645) stream iterators into different streams compare equal
Date Wed, 28 Nov 2007 20:31:43 GMT


Travis Vitek commented on STDCXX-645:

In most cases the iterator is going to be used in a loop which calls op!= and op++ repeatedly.
In this case op== would get called one time more than op++. Of course there are some scenerios
where op++ is called more frequently than op== [std::distance or std::advance], but I don't
believe that those are the most common use cases for an istream_iterator.

If we fix op++, then op== becomes a pointer comparison and op++ gets an additional assignment.
I think fixing op++ would be the preferred solution if we are just counting instructions.

> stream iterators into different streams compare equal
> -----------------------------------------------------
>                 Key: STDCXX-645
>                 URL:
>             Project: C++ Standard Library
>          Issue Type: Bug
>          Components: 24. Iterators
>    Affects Versions: 4.1.3, 4.2.0
>            Reporter: Mark Brown
> As Travis says in his reply to my post here:
>     Given p1 and p2, it is pretty clear to me that the two iterators are both
non-end-of-stream type, and they are both created on different streams. The streams are different,
so the iterators should not compare equal. I guess one could claim that p6 conflicts
with 24.5 p3 because 'end-of-stream' isn't clearly defined, but in this particular case that
doesn't matter.
> This program aborts with stdcxx but not with gcc:
> #include <assert.h>
> #include <iterator>
> #include <sstream>
> int main ()
> {
>     std::istringstream a ("1");
>     std::istream_iterator<int> i (a);
>     std::istringstream b ("2");
>     std::istream_iterator<int> j (b);
>     assert (!(i == j));
> } 

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message