Last active
July 27, 2017 11:34
-
-
Save odeblic/8c1e437501360c4316cc09ef71b30836 to your computer and use it in GitHub Desktop.
Study of primitive built-in types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <typeinfo> | |
#define PRINT_EXPR(T) do { std::cout << "parameter: " << #T << "\t\t\t\ttype: " << typeid(T).name() << std::endl; } while(false); | |
#define PRINT_TYPE(T) do { T val; std::cout << "parameter: " << #T << "\t\t\t\ttype: " << typeid(val).name() << std::endl; } while(false); | |
template <typename T> | |
void print(T t) | |
{ | |
std::cout << "type: " << typeid(T).name() << " value: " << t << std::endl; | |
} | |
int main() | |
{ | |
/* | |
PRINT_EXPR(1); | |
PRINT_EXPR(1u); | |
PRINT_EXPR(1l); | |
PRINT_EXPR(1ul); | |
PRINT_EXPR(1.f); | |
PRINT_EXPR(1.); | |
PRINT_EXPR('c'); | |
PRINT_EXPR("s"); | |
PRINT_EXPR("ss"); | |
PRINT_EXPR("sss"); | |
*/ | |
PRINT_TYPE(char); | |
PRINT_TYPE(signed char); | |
PRINT_TYPE(unsigned char); | |
PRINT_TYPE(short); | |
PRINT_TYPE(signed short); | |
PRINT_TYPE(unsigned short); | |
PRINT_TYPE(int); | |
PRINT_TYPE(signed int); | |
PRINT_TYPE(unsigned int); | |
PRINT_TYPE(long); | |
PRINT_TYPE(signed long); | |
PRINT_TYPE(unsigned long); | |
PRINT_TYPE(long long); | |
PRINT_TYPE(signed long long); | |
PRINT_TYPE(unsigned long long); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment