24 #ifndef util_TypeName_hpp
25 #define util_TypeName_hpp
34 template<
typename T >
36 static std::string value() {
return std::string(
typeid(T).name() ); }
41 #define GENERATE_SIMPLE_TYPE_NAME_VALUE( T ) \
42 template<> struct TypeName< T > { \
43 static std::string value() { return std::string( # T ); } \
46 GENERATE_SIMPLE_TYPE_NAME_VALUE(
void );
47 GENERATE_SIMPLE_TYPE_NAME_VALUE(
char );
48 GENERATE_SIMPLE_TYPE_NAME_VALUE(
unsigned char );
49 GENERATE_SIMPLE_TYPE_NAME_VALUE(
short );
50 GENERATE_SIMPLE_TYPE_NAME_VALUE(
unsigned short );
51 GENERATE_SIMPLE_TYPE_NAME_VALUE(
int );
52 GENERATE_SIMPLE_TYPE_NAME_VALUE(
unsigned int );
53 GENERATE_SIMPLE_TYPE_NAME_VALUE(
long );
54 GENERATE_SIMPLE_TYPE_NAME_VALUE(
unsigned long );
55 GENERATE_SIMPLE_TYPE_NAME_VALUE(
float );
56 GENERATE_SIMPLE_TYPE_NAME_VALUE(
double );
57 GENERATE_SIMPLE_TYPE_NAME_VALUE( std::complex<float> );
58 GENERATE_SIMPLE_TYPE_NAME_VALUE( std::complex<double> );
59 GENERATE_SIMPLE_TYPE_NAME_VALUE( std::string );
63 template<
typename T >
64 struct TypeName< const T >
66 static std::string value()
67 {
return std::string(
"const ").append( TypeName<T>::value() ); }
70 template<
typename T >
71 struct TypeName< T * >
73 static std::string value()
74 {
return std::string( TypeName<T>::value() ).append(
" *" ); }
77 template<
typename T >
78 struct TypeName< T & >
80 static std::string value()
81 {
return std::string( TypeName<T>::value() ).append(
" &" ); }
86 std::string type_name_array(
const std::string & ,
unsigned );
88 template<
typename T ,
unsigned N >
89 struct TypeName< T[N] >
91 static std::string value()
92 {
return type_name_array( TypeName<T>::value() , N ); }
95 template<
typename T >
96 std::string type_name_array(
unsigned n )
97 {
return type_name_array( TypeName<T>::value() , n ); }
101 std::string type_name_vector(
const std::string & ,
unsigned = 0 );
103 template<
typename T >
104 struct TypeName< std::vector<T> >
106 static std::string value()
107 {
return type_name_vector( TypeName<T>::value() ); }
110 template<
typename T >
111 std::string type_name_vector(
unsigned n = 0 )
112 {
return type_name_vector( TypeName<T>::value() , n ); }