
22 May
2008
22 May
'08
2:38 p.m.
Corrado Zoccolo wrote:
There is still a problem with this approach. The non overloaded operators || and && will usually do the wrong thing, causing the tribool to be first converted to bool, and then to go through the short-circuited evaluation. [snip] You should disable operators || and && completely using private overloads.
That's true. It would probably cause some initial confusion, but better to be surprised with a compiler error than an obscure logic error! :) There's also the issue of backwards-compatibility, but I think the default behavior should be to throw a compiler error when attempting to use operators || or && with a tribool. That could be resolved with a simple preprocessor macro to re-enable || and &&, though. - Jim