This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
The evil return of "convertable to bool"
- From: chris <caj at cs dot york dot ac dot uk>
- To: libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Tue, 26 Oct 2004 13:24:16 +0100
- Subject: The evil return of "convertable to bool"
Sorry for bringing this up again, but I just wanted it to be on the list
in case someone wants to query it later...
In the currently online <tuple> specification, the operator< is defined
as returning:
(bool)(get<0>(t) < get<0>(u)) || !((bool)(get<0>(u) < get<0>(t)) &&
(ttail < utail)
I asked where the various (bool)s were there, and was told (as has been
discussed previously) that they are there as the return values of these
functions only have to be convertable to bool and may overload || and
&&. I did not however put in the casts, as if it was decided that
libstdc++ had to cast everything to bool which we were going to then
apply && or || to, then this would involve (I believe) a fairly complete
look through the library (for example, these bool casts aren't on
operator< on std::pairand much of the contents of <algorithm>).
Chris