typeinfo / typeid output

后端 未结 1 1074
孤独总比滥情好
孤独总比滥情好 2021-02-08 17:19

I\'m currently trying to debug a piece of simple code and wish to see how a specific variable type changes during the program.

I\'m using the typeinfo header file so I c

相关标签:
1条回答
  • 2021-02-08 17:58

    I don't know if such a list exists, but you can make a small program to 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*);
        //...
    }
    
    0 讨论(0)
提交回复
热议问题