aboutsummaryrefslogtreecommitdiffstats
path: root/util/system/type_name.h
blob: b6619aba3fa25a0dee4d47175e63f76ada872901 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#pragma once

#include <util/generic/string.h>
#include <util/string/subst.h>

#include <typeindex>
#include <typeinfo>

// Consider using TypeName function family.
TString CppDemangle(const TString& name);

// TypeName function family return human readable type name.

TString TypeName(const std::type_info& typeInfo);
TString TypeName(const std::type_index& typeInfo);

// Works for types known at compile-time
// (thus, does not take any inheritance into account)
template <class T>
inline TString TypeName() {
    return TypeName(typeid(T));
}

// Works for dynamic type, including complex class hierarchies.
// Also, distinguishes between T, T*, T const*, T volatile*, T const volatile*,
// but not T and T const.
template <class T>
inline TString TypeName(const T& t) {
    return TypeName(typeid(t));
}