There is something which has been ignored by all the WU's so far -- the type of the expression. In C++ all expressions are statically typed, so the compiler must know what all the types of the expressions are. For the *simple* <grin> case, the following rules are obeyed for `( T ? A : B )`

:

- If A and B are of the same type, then the entire expression has that type.
- If A can be converted to B, it does so.
- Then the other way is considered.

This is the simple case because we have ignored l/r-values, and const/volatile cases. It happens that there are some more conditions for those cases. Language lawyers may refer to The Good Book for more details.

Why is this important? Because it allows us to get the type of an expression without having to evaluate it. Suppose we have the following functions:

template <typename T> std::string get_type_name(T x) {return "unknown";}…