All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
common.h
Go to the documentation of this file.
1 #ifndef uscript_common_h
2 #define uscript_common_h
3 
4 #include <string_view>
5 
6 // #define DEBUG_TRACE_EXECUTION
7 // #define DEBUG_PRINT_CODE
8 
9 // Get the name of a type
10 // From: https://stackoverflow.com/questions/81870/is-it-possible-to-print-a-variables-type-in-standard-c
11 template <typename T>
12 constexpr auto type_name()
13 {
14  std::string_view name, prefix, suffix;
15 #ifdef __clang__
16  name = __PRETTY_FUNCTION__;
17  prefix = "auto type_name() [T = ";
18  suffix = "]";
19 #elif defined(__GNUC__)
20  name = __PRETTY_FUNCTION__;
21  prefix = "constexpr auto type_name() [with T = ";
22  suffix = "]";
23 #elif defined(_MSC_VER)
24  name = __FUNCSIG__;
25  prefix = "auto __cdecl type_name<";
26  suffix = ">(void)";
27 #endif
28  name.remove_prefix(prefix.size());
29  name.remove_suffix(suffix.size());
30  return name;
31 }
32 
33 #endif
then echo fcl name
constexpr auto type_name()
Definition: common.h:12