Tatooine
type_to_str.h
Go to the documentation of this file.
1#ifndef TATOOINE_TYPE_TO_STR_H
2#define TATOOINE_TYPE_TO_STR_H
3//==============================================================================
4namespace tatooine {
5//==============================================================================
6template <typename>
7struct type_to_str_false_type : std::false_type {};
8//------------------------------------------------------------------------------
9template <typename Data>
10constexpr auto type_to_str() -> std::string_view {
11 static_assert(type_to_str_false_type<Data>::value, "unknown type");
12 return "";
13}
14//------------------------------------------------------------------------------
15template <>
16constexpr auto type_to_str<double>() -> std::string_view {
17 return "double";
18}
19//------------------------------------------------------------------------------
20template <>
21constexpr auto type_to_str<long double>() -> std::string_view {
22 return "long double";
23}
24//------------------------------------------------------------------------------
25template <>
26constexpr auto type_to_str<float>() -> std::string_view {
27 return "float";
28}
29//------------------------------------------------------------------------------
30template <>
31constexpr auto type_to_str<int>() -> std::string_view {
32 return "int";
33}
34//------------------------------------------------------------------------------
35template <>
36constexpr auto type_to_str<unsigned int>() -> std::string_view {
37 return "unsigned int";
38}
39//------------------------------------------------------------------------------
40template <>
41constexpr auto type_to_str<long>() -> std::string_view {
42 return "long";
43}
44//------------------------------------------------------------------------------
45template <>
46constexpr auto type_to_str<unsigned long>() -> std::string_view {
47 return "unsigned long";
48}
49//------------------------------------------------------------------------------
50template <>
51constexpr auto type_to_str<long long>() -> std::string_view {
52 return "long long";
53}
54//------------------------------------------------------------------------------
55template <>
56constexpr auto type_to_str<unsigned long long>() -> std::string_view {
57 return "unsigned long long";
58}
59//------------------------------------------------------------------------------
60template <>
61constexpr auto type_to_str<char>() -> std::string_view {
62 return "char";
63}
64//------------------------------------------------------------------------------
65template <>
66constexpr auto type_to_str<unsigned char>() -> std::string_view {
67 return "unsigned char";
68}
69//==============================================================================
70} // namespace tatooine
71//==============================================================================
72#endif
Definition: algorithm.h:6
constexpr auto type_to_str< double >() -> std::string_view
Definition: type_to_str.h:16
constexpr auto type_to_str() -> std::string_view
Definition: type_to_str.h:10
constexpr auto type_to_str< unsigned int >() -> std::string_view
Definition: type_to_str.h:36
constexpr auto type_to_str< unsigned char >() -> std::string_view
Definition: type_to_str.h:66
constexpr auto type_to_str< long >() -> std::string_view
Definition: type_to_str.h:41
constexpr auto type_to_str< long double >() -> std::string_view
Definition: type_to_str.h:21
constexpr auto type_to_str< int >() -> std::string_view
Definition: type_to_str.h:31
constexpr auto type_to_str< char >() -> std::string_view
Definition: type_to_str.h:61
constexpr auto type_to_str< float >() -> std::string_view
Definition: type_to_str.h:26
constexpr auto type_to_str< unsigned long long >() -> std::string_view
Definition: type_to_str.h:56
constexpr auto type_to_str< unsigned long >() -> std::string_view
Definition: type_to_str.h:46
constexpr auto type_to_str< long long >() -> std::string_view
Definition: type_to_str.h:51
Definition: type_to_str.h:7