Github   Telegram
Loading...
Searching...
No Matches
demangle.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <chrono>
7#include <string>
8#include <typeindex>
9
10USERVER_NAMESPACE_BEGIN
11
13namespace compiler {
14
16std::string GetTypeName(std::type_index type);
17
18namespace detail {
19
20template <class T>
21struct TypeNameHelper {
22 static std::string Get() { return GetTypeName(typeid(T)); }
23};
24
25template <>
26struct TypeNameHelper<std::string> {
27 static std::string Get() { return "std::string"; }
28};
29
30template <>
31struct TypeNameHelper<std::chrono::nanoseconds> {
32 static std::string Get() { return "std::chrono::nanoseconds"; }
33};
34
35template <>
36struct TypeNameHelper<std::chrono::microseconds> {
37 static std::string Get() { return "std::chrono::microseconds"; }
38};
39
40template <>
41struct TypeNameHelper<std::chrono::milliseconds> {
42 static std::string Get() { return "std::chrono::milliseconds"; }
43};
44
45template <>
46struct TypeNameHelper<std::chrono::seconds> {
47 static std::string Get() { return "std::chrono::seconds"; }
48};
49
50template <>
51struct TypeNameHelper<std::chrono::minutes> {
52 static std::string Get() { return "std::chrono::minutes"; }
53};
54
55template <>
56struct TypeNameHelper<std::chrono::hours> {
57 static std::string Get() { return "std::chrono::hours"; }
58};
59
60template <>
61struct TypeNameHelper<std::chrono::steady_clock::time_point> {
62 static std::string Get() { return "std::chrono::steady_clock::time_point"; }
63};
64
65template <>
66struct TypeNameHelper<std::chrono::system_clock::time_point> {
67 static std::string Get() { return "std::chrono::system_clock::time_point"; }
68};
69
70} // namespace detail
71
79template <typename T>
80std::string GetTypeName() {
81 return detail::TypeNameHelper<T>::Get();
82}
83
84} // namespace compiler
85
86USERVER_NAMESPACE_END