18 #ifndef LIBCWD_TYPE_INFO_H
19 #define LIBCWD_TYPE_INFO_H
21 #ifndef LIBCWD_PRIVATE_THREADING_H
24 #ifndef LIBCW_TYPEINFO
25 #define LIBCW_TYPEINFO
36 extern char const* make_label(
char const* mangled_name);
39 struct size_of_completed {
40 static constexpr
size_t size =
sizeof(T);
43 struct size_of_not_completed {
44 static constexpr
size_t size = 0;
50 static size_of_completed<T> test(
int (*)[
sizeof(U)]);
53 static size_of_not_completed test(...);
55 static constexpr
size_t value = decltype(test<T>(
nullptr))::size;
59 size_t sizeof_ref_v = sizeof_ref<T>::value;
88 void init(
char const* type_encoding,
size_t s,
size_t rs)
93 M_dem_name = _private_::make_label(type_encoding);
105 namespace _private_ {
107 extern char const* extract_exact_name(
char const*,
char const* LIBCWD_COMMA_TSD_PARAM);
116 static type_info_ct S_value;
117 static bool S_initialized;
119 static type_info_ct
const& value();
125 struct type_info<T*> {
127 static type_info_ct S_value;
128 static bool S_initialized;
130 static type_info_ct
const& value();
136 struct type_info<void*> {
138 static type_info_ct S_value;
139 static bool S_initialized;
141 static type_info_ct
const& value();
146 type_info_ct type_info<T>::S_value;
150 bool type_info<T>::S_initialized;
154 type_info_ct
const& type_info<T>::value()
158 S_value.init(
typeid(T).name(),
sizeof(T), 0);
159 S_initialized =
true;
166 type_info_ct type_info<T*>::S_value;
170 bool type_info<T*>::S_initialized;
174 type_info_ct
const& type_info<T*>::value()
178 S_value.init(
typeid(T*).name(),
sizeof(T*), sizeof_ref_v<T>);
179 S_initialized =
true;
192 struct libcwd_type_info_exact {
194 static ::libcwd::type_info_ct S_value;
195 static bool S_initialized;
197 static ::libcwd::type_info_ct
const& value();
202 struct libcwd_type_info_exact<T*> {
204 static ::libcwd::type_info_ct S_value;
205 static bool S_initialized;
207 static ::libcwd::type_info_ct
const& value();
212 struct libcwd_type_info_exact<void*> {
214 static ::libcwd::type_info_ct S_value;
215 static bool S_initialized;
217 static ::libcwd::type_info_ct
const& value();
224 bool libcwd_type_info_exact<T>::S_initialized;
231 S_value.
init(::libcwd::_private_::extract_exact_name(
typeid(libcwd_type_info_exact<T>).name(),
typeid(T).name() LIBCWD_COMMA_TSD_INSTANCE),
sizeof(T), 0);
232 S_initialized =
true;
241 bool libcwd_type_info_exact<T*>::S_initialized;
248 S_value.
init(::libcwd::_private_::extract_exact_name(
typeid(libcwd_type_info_exact<T*>).name(),
typeid(T*).name() LIBCWD_COMMA_TSD_INSTANCE),
sizeof(T*), ::libcwd::_private_::sizeof_ref_v<T>);
249 S_initialized =
true;
259 #ifndef LIBCWD_DOXYGEN
288 return ::libcwd_type_info_exact<T>::value();
304 return _private_::type_info<T>::value();
307 extern type_info_ct
const unknown_type_info_c;
Class that holds type information for debugging purposes.  Returned by type_info_of().
Definition: type_info.h:67
size_t M_type_size
sizeof(T).
Definition: type_info.h:69
char const * M_name
Encoded type of T (as returned by typeid(T).name()).
Definition: type_info.h:71
type_info_ct()
Default constructor.
Definition: type_info.h:78
size_t M_type_ref_size
sizeof(*T) or 0 when T is not a pointer (or a pointer to an incomplete type).
Definition: type_info.h:70
char const * name() const
The encoded type name (as returned by typeid(T).name()).
Definition: type_info.h:98
size_t ref_size() const
sizeof(*T) or 0 when T is not a pointer (or a pointer to an incomplete type).
Definition: type_info.h:102
void init(char const *type_encoding, size_t s, size_t rs)
Construct a type_info_ct object for a type (T) with encoding type_encoding, size s and size of refere...
Definition: type_info.h:88
size_t size() const
sizeof(T).
Definition: type_info.h:100
char const * demangled_name() const
The demangled type name.
Definition: type_info.h:96
type_info_ct(int)
Constructor used for unknown_type_info_c.
Definition: type_info.h:83
char const * M_dem_name
Demangled type name of T.
Definition: type_info.h:72
type_info_ct const & type_info_of()
Get type information of a given class or type.
Definition: type_info.h:286
namespace for libcwd.
Definition: debug.cc:87