Old Wolf wrote in news:84**************************@posting.google.c om
in comp.lang.c++:
In the documentation for std::find, it says:
find returns the first iterator i in the range [first, last)
for which the following condition holds:
*i == value.
However in my compiler's headers the implementation is:
template <class InputIterator, class T>
InputIterator find (InputIterator first, InputIterator last, const
T& value) {
while (first != last && *first != value)
++first;
return first;
}
So operator!= is required and operator== isn't. Is this conforming?
Iterators / Input Iterators 24.1.1/2
In Table 72, the term the domain of == is used in the ordinary
mathematical sense to denote the set of values over which == is
(required to be) defined. This set can change over time. Each algorithm
places additional requirements on the domain of == for the iterator
values it uses. These requirements can be inferred from the uses that
algorithm makes of == and !=. [Example: the call find(a,b,x) is defined
only if the value of a has the property p defined as follows: b has
property p and a value i has property p if (*i==x) or if (*i!=x and ++i
has property p). ]
The relevent two entries from table 72 (a and b are Input Iterators):
+-------+---------------------+-------------------------------+
|a == b | convertible to bool | == is an equivalence relation |
| | | over itsdomain. |
+-------+---------------------+-------------------------------+
|a != b |convertible to bool | bool(a==b) != bool(a!=b) over |
| | | the domain of == |
+-------+---------------------+-------------------------------+
IOW, It says for an Input Iterator a != b is !bool( a == b ) without
actually requiring that its implemented in that way.
Rob.
--
http://www.victim-prime.dsl.pipex.com/