This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of NAD status.
Section: 25.3.5.3 [input.iterators] Status: NAD Submitter: Corwin Joy Opened: 2002-12-11 Last modified: 2016-01-28
Priority: Not Prioritized
View other active issues in [input.iterators].
View all other issues in [input.iterators].
View all issues with NAD status.
Discussion:
In section 25.3.5.3 [input.iterators] table 72 - 'Input Iterator Requirements' we have as a postcondition of *a: "If a==b and (a, b) is in the domain of == then *a is equivalent to *b".
In section [istreambuf.iterator::equal] it states that "istreambuf_iterator::equal returns true if and only if both iterators are at end-of-stream, or neither is at end-of-stream, regardless of what streambuf object they use." (My emphasis).
The defect is that either 'equivalent' needs to be more precisely defined or the conditions for equality in [istreambuf.iterator::equal] are incorrect. (Or both).
Consider the following example:
#include <iostream> #include <fstream> #include <iterator> using namespace std; int main() { ifstream file1("file1.txt"), file2("file2.txt"); istreambuf_iterator<char> f1(file1), f2(file2); cout << "f1 == f2 : " << boolalpha << (f1 == f2) << endl; cout << "f1 = " << *f1 << endl; cout << "f2 = " << *f2 << endl; return 0; }
Now assuming that neither f1 or f2 are at the end-of-stream then f1 == f2 by [istreambuf.iterator::equal].
However, it is unlikely that *f1 will give the same value as *f2 except by accident.
So what does *f1 'equivalent' to *f2 mean? I think the standard should be clearer on this point, or at least be explicit that this does not mean that *f1 and *f2 are required to have the same value in the case of input iterators.
Proposed resolution:
Rationale:
The two iterators aer not in the domain of ==