The type of a ternary conditional expression is the common type two which both operands are convertible. You can definitely not perform "dynamic overload resolution", as you seem to be suggesting.
Since there is no common type for int
and char const *
, the code won't even compile (as you surely noticed when you tested this).
(You may be thrilled to know that the ternary conditional is used precisely because of those semantics in the implementation of the std::common_type
trait class template, together with decltype
.)
(If the condition is known statically, such as sizeof(int) != 7
, then you can use template specialization to write similar-looking code that does perform conditional overload resolution, but of course statically.)