This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]