The typeid operator can be applied to types and expressions and will return a reference to a std::type_info object representing the type (of the expression).
When applied to polymorphic types (except during construction and destruction), the typeid operator will evaluate the expression and return the dynamic type of the expression.
Compiler Explorer link: https://compiler-explorer.com/z/YxePzhbhE
@simontoth Worth noting that one big downside of typeid() is that it is a template function which accepts a paramter by value. So if you give it a "const int&" it will copy it into an "int". This is kinda crappy output. using boost::typeindex::type_id_with_cvr; helps with that.
@braincell boost::typeindex post is scheduled for tomorrow.
But typeid is not a function, it's an operator, I don't think it should make copies, but I will doublecheck.
@simontoth I know this about the GCC implementation from 5 years ago, and I think MSVC did the same. It's implementation specific, so subject to change I guess.