c++ - typeinfo / typeid output -
i'm trying debug piece of simple code , wish see how specific variable type changes during program.
i'm using typeinfo header file can utilise typeid.name(). i'm aware typeid.name() compiler specific output might not particularly helpful or standard.
i'm using gcc
cannot find list of potential output despite searching, assuming list of typeid output symbols exist. don't want sort of casting based on output or manipulate kind of data, follow type.
#include <iostream> #include <typeinfo> int main() { int = 10; cout << typeid(int).name() << endl; }
is there symbol list anywhere?
i don't know if such list exists, can make small program print them out:
#include <iostream> #include <typeinfo> #define print_name(x) std::cout << #x << " - " << typeid(x).name() << '\n' int main() { print_name(char); print_name(signed char); print_name(unsigned char); print_name(short); print_name(unsigned short); print_name(int); print_name(unsigned int); print_name(long); print_name(unsigned long); print_name(float); print_name(double); print_name(long double); print_name(char*); print_name(const char*); //... }
Comments
Post a Comment