10#ifndef LIBCWD_TYPE_INFO_H
11#define LIBCWD_TYPE_INFO_H
19extern char const* make_label(
char const* mangled_name);
22struct size_of_completed
24 static constexpr size_t size =
sizeof(T);
27struct size_of_not_completed
29 static constexpr size_t size = 0;
36 static size_of_completed<T> test(
int (*)[
sizeof(U)]);
39 static size_of_not_completed test(...);
41 static constexpr size_t value =
decltype(test<T>(
nullptr))::size;
45size_t sizeof_ref_v = sizeof_ref<T>::value;
77 void init(
char const* type_encoding,
size_t s,
size_t rs)
81 name_ = type_encoding;
96extern char const* extract_exact_name(
char const*,
char const*);
106 static TypeInfo s_value_;
107 static bool s_initialized_;
110 static TypeInfo
const& value();
119 static TypeInfo s_value_;
120 static bool s_initialized_;
123 static TypeInfo
const& value();
129struct type_info<void*>
132 static TypeInfo s_value_;
133 static bool s_initialized_;
136 static TypeInfo
const& value();
141TypeInfo type_info<T>::s_value_;
145bool type_info<T>::s_initialized_;
149TypeInfo
const& type_info<T>::value()
153 s_value_.init(
typeid(T).name(),
sizeof(T), 0);
154 s_initialized_ =
true;
161TypeInfo type_info<T*>::s_value_;
165bool type_info<T*>::s_initialized_;
169TypeInfo
const& type_info<T*>::value()
173 s_value_.init(
typeid(T*).name(),
sizeof(T*), sizeof_ref_v<T>);
174 s_initialized_ =
true;
186struct libcwd_type_info_exact
189 static ::libcwd::TypeInfo s_value_;
190 static bool s_initialized_;
193 static ::libcwd::TypeInfo
const& value();
198struct libcwd_type_info_exact<T*>
201 static ::libcwd::TypeInfo s_value_;
202 static bool s_initialized_;
205 static ::libcwd::TypeInfo
const& value();
210struct libcwd_type_info_exact<void*>
213 static ::libcwd::TypeInfo s_value_;
214 static bool s_initialized_;
217 static ::libcwd::TypeInfo
const& value();
224bool libcwd_type_info_exact<T>::s_initialized_;
231 s_value_.init(::libcwd::_private_::extract_exact_name(
232 typeid(libcwd_type_info_exact<T>).name(),
236 s_initialized_ =
true;
245bool libcwd_type_info_exact<T*>::s_initialized_;
252 s_value_.init(::libcwd::_private_::extract_exact_name(
253 typeid(libcwd_type_info_exact<T*>).name(),
256 ::libcwd::_private_::sizeof_ref_v<T>);
257 s_initialized_ =
true;
267#ifndef LIBCWD_DOXYGEN
292 return ::libcwd_type_info_exact<T>::value();
307 return _private_::type_info<T>::value();
Class that holds type information for debugging purposes. Returned by type_info_of().
Definition type_info.h:55
void init(char const *type_encoding, size_t s, size_t rs)
Construct a TypeInfo object for a type (T) with encoding type_encoding, size s and size of reference ...
Definition type_info.h:77
char const * demangled_name_
Demangled type name of T.
Definition type_info.h:60
size_t dereferenced_type_size_
sizeof(*T) or 0 when T is not a pointer (or a pointer to an incomplete type).
Definition type_info.h:58
TypeInfo(int)
Constructor used for unknown_type_info_c.
Definition type_info.h:71
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:91
size_t size() const
sizeof(T).
Definition type_info.h:89
char const * name() const
The encoded type name (as returned by typeid(T).name()).
Definition type_info.h:87
size_t type_size_
sizeof(T).
Definition type_info.h:57
char const * demangled_name() const
The demangled type name.
Definition type_info.h:85
char const * name_
Encoded type of T (as returned by typeid(T).name()).
Definition type_info.h:59
TypeInfo()
Default constructor.
Definition type_info.h:66