Template argument type | Sololearn: Learn to code for FREE!

0

Template argument type

I was just trying to print whether argument is map or unordered map. It is showing but with some random numbers. Is there any other way ? I remember something related to ::value but can't recall perfectly what it was... Any help on this ? https://code.sololearn.com/c95YJ40vw531/?ref=app

6/7/2021 8:36:51 PM

Ketan Lalcheta

1 Answer

New Answer

+4

The name of a type returned from typeid() is implementation specific, but you can demangle it. Here is an example by another user: https://code.sololearn.com/ccr76hQ048un/?ref=app Otherwise you would probably have to specialize the function template for whatever types you want to print, or perform type traits comparisons via std::is_same<>, which is somewhat tedious.