为什么不能重载三元运算符?

Why can't a ternary operator be overloaded?

我一直对此很好奇,但从未找到可靠的答案或易于理解的解释。我试过其他运营商,效果很好。这个运算符尤其有趣。我只是无法理解它。

stroustrup 的常见问题解答:

There is no fundamental reason to disallow overloading of ?:. I just didn't see the need to introduce the special case of overloading a ternary operator. Note that a function overloading expr1?expr2:expr3 would not be able to guarantee that only one of expr2 and expr3 was executed.