rel_ops (was Re: GCC 3.1 Release)
Gabriel Dos Reis
gdr@codesourcery.com
Fri Apr 19 12:59:00 GMT 2002
Joe Buck <Joe.Buck@synopsys.com> writes:
[...]
| 2) the types of both arguments are constrained to be the same.
|
| Point #2 and the rules of C++ guarantee that any more-specific operator!=
| definition will always be preferred to this one guarantee that there will
| never be an ambiguity between this definition and any user definition of
| operator!= that uses the same type for both arguments.
With an appropriate definition of "more-specific", the code I just sent
is a counterexample to the above statement :-)
| Conflicts will only occur if the user definition (or more specific
| definition in the system library) permits the arguments to be of different
| types but allows them to be of the same type. If this happens, then it is
| possible that, for a call to operator!= with two arguments that are of
| exactly the same type, the two definitions of operator!= will be seen as
| equal cost, and neither will be seen as a specialization of the other,
| so the compiler will report an ambiguity.
Not always. Sometimes, it will take the std::rel_ops version because
it provides a "best match" (according to the standard).
| The way to solve it is to add a third definition that will be seen by
| the compiler as more specific than either of the alternatives.
Actually, this might not be always practical.
-- Gaby
More information about the Libstdc++
mailing list