This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: rel_ops (was Re: GCC 3.1 Release)
- From: Gabriel Dos Reis <gdr at codesourcery dot com>
- To: Joe Buck <Joe dot Buck at synopsys dot com>
- Cc: phil at jaj dot com (Phil Edwards), Richard dot Kreckel at uni-mainz dot de, gdr at codesourcery dot com (Gabriel Dos Reis), mark at codesourcery dot com (Mark Mitchell), gcc at gcc dot gnu dot org (gcc at gcc dot gnu dot org), bkoz at redhat dot com (bkoz at redhat dot com), libstdc++ at gcc dot gnu dot org (libstdc++ at gcc dot gnu dot org), Christian dot Bauer at uni-mainz dot de (Christian Bauer)
- Date: 19 Apr 2002 21:59:42 +0200
- Subject: Re: rel_ops (was Re: GCC 3.1 Release)
- Organization: CodeSourcery, LLC
- References: <200204172336.QAA06668@atrus.synopsys.com>
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