Just to see how it worked, I looked at the libstdc++ implementation of std::common_type
in the header type_traits
. I have to admit that I don\'t really
Long Story Short: The decltype is making the C++ compiler determine the closest ancestor type for it.
Tertiary Operator's have the resulting static type of the closest ancestor of the two possible expressions.
E.g:
A inherits from B
X inherits from Y inherits from B
? :
= // this is how the C++ parser sees it
This is how the C++ language works. The decltype just makes the typedef be the static type of the result of that expression (whatever type the C++ compiler determines it to be)