This file looks large and may slow your browser down if we attempt
to syntax highlight it, so we are showing it without any
pretty colors.
Highlight
it anyway.
| 1 |
#ifndef CHILON_TYPE_NAME_HPP |
| 2 |
#define CHILON_TYPE_NAME_HPP |
| 3 |
|
| 4 |
#include <chilon/iterator_range.hpp> |
| 5 |
|
| 6 |
namespace chilon { |
| 7 |
|
| 8 |
template <class T> |
| 9 |
range type_name() { |
| 10 |
// TODO: support other compilers etc. |
| 11 |
char const *name = typeid(T).name(); |
| 12 |
if (*name == 'N') { |
| 13 |
++name; |
| 14 |
int length; |
| 15 |
do { |
| 16 |
length = *name - '0'; |
| 17 |
|
| 18 |
++name; |
| 19 |
while (*name >= '0' && *name <= '9') { |
| 20 |
length *= 10; |
| 21 |
length += *name - '0'; |
| 22 |
++name; |
| 23 |
} |
| 24 |
|
| 25 |
name += length; |
| 26 |
} while (*name != 'E'); |
| 27 |
|
| 28 |
return range(name - length, name); |
| 29 |
} |
| 30 |
else { |
| 31 |
while (*name >= '0' && *name <= '9') ++name; |
| 32 |
return to_range(name); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
} |
| 37 |
#endif |