It is reasonable that sizeof
and typeid
cannot be overloaded, but I can't see the harm in overloading ?:
, .*
and .
. Are there technical reasons for this?
To quote Bjarne 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.
...
Operator . (dot) could in principle be overloaded using the same technique as used for ->. However, doing so can lead to questions about whether an operation is meant for the object overloading
.
or an object referred to by.
... This problem can be solved in several ways. At the time of standardization, it was not obvious which way would be best.
Source
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With