lintel 0.2.0
Loading...
Searching...
No Matches
TypeName.h
Go to the documentation of this file.
1#pragma once
2
3#include <string_view>
4
5namespace lintel {
9template<typename T> constexpr std::string_view type_name()
10{
11 std::string_view name, prefix, suffix;
12#ifdef __clang__
14 prefix = "std::string_view lintel::type_name() [T = ";
15 suffix = "]";
16#elif defined(__GNUC__)
18 prefix = "constexpr std::string_view lintel::type_name() [with T = ";
19 suffix = "; std::string_view = std::basic_string_view<char>]";
20#elif defined(_MSC_VER)
21 name = __FUNCSIG__;
22 prefix =
23 "class std::basic_string_view<char,struct std::char_traits<char> > "
24 "__cdecl lintel::type_name<";
25 suffix = ">(void)";
26#endif
27 name.remove_prefix(prefix.size());
28 name.remove_suffix(suffix.size());
29 auto pos = name.rfind("::");
30 if (pos != std::string_view::npos) { name.remove_prefix(pos + 2); }
31 return name;
32}
33}// namespace lintel
Definition BaseFeature.h:6
constexpr std::string_view type_name()
Definition TypeName.h:9