Falls du es noch nicht kennst, solltest du dir _PRETTY_FUNCTION_
angucken.
Dieses "Makro" ist sehr hilfreich, im beim Loggen von Debuginfos und
generell beim Umgang mit Templates. Vor allem das folgende Beispiel ist
sehr hiflreich, wenn man mal keine Lust hat über type deduction
nachzudenken:
1 | #include <iostream>
|
2 | #include <type_traits>
|
3 |
|
4 | template<typename T>
|
5 | void foo() {
|
6 | std::cout << __PRETTY_FUNCTION__ << std::endl;
|
7 | }
|
8 |
|
9 | int main () {
|
10 | foo<int>();
|
11 | foo<int*>();
|
12 | foo<int const*>();
|
13 | foo<std::remove_pointer<int>::type>();
|
14 | foo<std::remove_pointer<int*>::type>();
|
15 | foo<std::remove_pointer<int const*>::type>();
|
16 | }
|
liefert
1 | void foo() [T = int]
|
2 | void foo() [T = int *]
|
3 | void foo() [T = const int *]
|
4 | void foo() [T = int]
|
5 | void foo() [T = int]
|
6 | void foo() [T = const int]
|
Mindestens gcc und clang kennen _PRETTY_FUNCTION_.