30#ifndef JAU_TYPE_TRAITS_QUERIES_HPP_
31#define JAU_TYPE_TRAITS_QUERIES_HPP_
59 return static_cast<uint64_t
>(rhs);
74 return !( lhs == rhs );
102 template <
typename T>
117#if defined(__cxx_rtti_available__)
118 return typeid(T).
name();
120 return "unnamed_type";
131 template <
typename T>
144 printf(
" Primary Type Categories\n");
145 printf(
" void %d\n", std::is_void_v<T>);
146 printf(
" null ptr %d\n", std::is_null_pointer_v<T>);
147 printf(
" integral %d\n", std::is_integral_v<T>);
148 printf(
" floating point %d\n", std::is_floating_point_v<T>);
149 printf(
" array %d\n", std::is_array_v<T>);
150 printf(
" enum %d\n", std::is_enum_v<T>);
151 printf(
" union %d\n", std::is_union_v<T>);
152 printf(
" class %d\n", std::is_class_v<T>);
153 printf(
" function %d\n", std::is_function_v<T>);
154 printf(
" pointer %d\n", std::is_pointer_v<T>);
155 printf(
" lvalue ref %d\n", std::is_lvalue_reference_v<T>);
156 printf(
" rvalue ref %d\n", std::is_rvalue_reference_v<T>);
157 printf(
" member obj ptr %d\n", std::is_member_object_pointer_v<T>);
158 printf(
" member func ptr %d\n", std::is_member_function_pointer_v<T>);
162 printf(
" Type Properties\n");
163 printf(
" const %d\n", std::is_const_v<T>);
164 printf(
" volatile %d\n", std::is_volatile_v<T>);
165 printf(
" trivial %d\n", std::is_trivial_v<T>);
166 printf(
" trivially_copy. %d\n", std::is_trivially_copyable_v<T>);
167 printf(
" standard_layout %d\n", std::is_standard_layout_v<T>);
168 printf(
" pod %d\n", std::is_standard_layout_v<T> && std::is_trivial_v<T>);
169 printf(
" unique_obj_rep %d\n", std::has_unique_object_representations_v<T>);
170 printf(
" empty %d\n", std::is_empty_v<T>);
171 printf(
" polymorphic %d\n", std::is_polymorphic_v<T>);
172 printf(
" abstract %d\n", std::is_abstract_v<T>);
173 printf(
" final %d\n", std::is_final_v<T>);
174 printf(
" aggregate %d\n", std::is_aggregate_v<T>);
175 printf(
" signed %d\n", std::is_signed_v<T>);
176 printf(
" unsigned %d\n", std::is_unsigned_v<T>);
177 #if __cplusplus > 202002L
179 printf(
" bounded_array %d\n", std::is_bounded_array_v<T>);
180 printf(
" unbounded_array %d\n", std::is_unbounded_array_v<T>);
181 printf(
" scoped enum %d\n", std::is_scoped_enum_v<T>);
186 printf(
" Composite Type Categories\n");
187 printf(
" fundamental %d\n", std::is_fundamental_v<T>);
188 printf(
" arithmetic %d\n", std::is_arithmetic_v<T>);
189 printf(
" scalar %d\n", std::is_scalar_v<T>);
190 printf(
" object %d\n", std::is_object_v<T>);
191 printf(
" compound %d\n", std::is_compound_v<T>);
192 printf(
" reference %d\n", std::is_reference_v<T>);
193 printf(
" member ptr %d\n", std::is_member_pointer_v<T>);
197 printf(
" Supported Operations\n");
198 printf(
" constructible %d {trivially %d, nothrow %d}\n",
199 std::is_constructible_v<T>,
200 std::is_trivially_constructible_v<T>, std::is_nothrow_constructible_v<T>);
201 printf(
" default_constructible %d {trivially %d, nothrow %d}\n",
202 std::is_default_constructible_v<T>,
203 std::is_trivially_default_constructible_v<T>, std::is_nothrow_default_constructible_v<T>);
204 printf(
" copy_constructible %d {trivially %d, nothrow %d}\n",
205 std::is_copy_constructible_v<T>,
206 std::is_trivially_copy_constructible_v<T>, std::is_nothrow_copy_constructible_v<T>);
207 printf(
" move_constructible %d {trivially %d, nothrow %d}\n",
208 std::is_move_constructible_v<T>,
209 std::is_trivially_move_constructible_v<T>, std::is_nothrow_move_constructible_v<T>);
210 printf(
" assignable %d {trivially %d, nothrow %d}\n",
211 std::is_assignable_v<T, T>,
212 std::is_trivially_assignable_v<T, T>, std::is_nothrow_assignable_v<T, T>);
213 printf(
" copy_assignable %d {trivially %d, nothrow %d}\n",
214 std::is_copy_assignable_v<T>,
215 std::is_trivially_copy_assignable_v<T>, std::is_nothrow_copy_assignable_v<T>);
216 printf(
" move_assignable %d {trivially %d, nothrow %d}\n",
217 std::is_move_assignable_v<T>,
218 std::is_trivially_move_assignable_v<T>, std::is_nothrow_move_assignable_v<T>);
219 printf(
" destructible %d {trivially %d, nothrow %d, virtual %d}\n",
220 std::is_destructible_v<T>,
221 std::is_trivially_destructible_v<T>, std::is_nothrow_destructible_v<T>,
222 std::has_virtual_destructor_v<T>);
223 printf(
" swappable %d {nothrow %d}\n",
224 std::is_swappable_v<T>, std::is_nothrow_swappable_v<T>);
228 #define JAU_TYPENAME_CUE(A) template<> struct jau::type_name_cue<A> { static const char * name() { return #A; } };
229 #define JAU_TYPENAME_CUE_ALL(A) JAU_TYPENAME_CUE(A) JAU_TYPENAME_CUE(A*) JAU_TYPENAME_CUE(const A*) JAU_TYPENAME_CUE(A&) JAU_TYPENAME_CUE(const A&)
243 template<
class,
class =
void >
259 template<
class,
class =
void >
282 #define TYPEDEF_CHECKER(checker, name) \
283 template<class C, typename T, typename = void> struct checker : std::false_type {}; \
284 template<class C, typename T> struct checker<C, T, typename std::enable_if< \
285 std::is_convertible<typename C::name, T>::value>::type> : std::true_type {}
288 #define TYPEDEF_CHECKER_STRICT(checker, name) \
289 template<class C, typename T, typename = void> struct checker : std::false_type {}; \
290 template<class C, typename T> struct checker<C, T, typename std::enable_if< \
291 std::is_same<typename C::name, T>::value>::type> : std::true_type {}
294 #define TYPEDEF_CHECKER_ANY(checker, name) \
295 template<class C, typename = void> struct checker : std::false_type {}; \
296 template<class C> struct checker<C, typename std::enable_if< \
297 !std::is_same<typename C::name*, void>::value>::type> : std::true_type {}
300 #define MVALUE_CHECKER(checker, name, val) \
301 template<class C, typename = void> struct checker : std::false_type {}; \
302 template<class C> struct checker<C, typename std::enable_if< \
303 std::is_convertible<decltype(C::name), const decltype(val)>::value && C::name == val>::type> : std::true_type {}
305 #define MVALUE_CHECKER_STRICT(checker, name, val) \
306 template<class C, typename = void> struct checker : std::false_type {}; \
307 template<class C> struct checker<C, typename std::enable_if< \
308 std::is_same<decltype(C::name), const decltype(val)>::value && C::name == val>::type> : std::true_type {}
312 #define MTYPE_CHECKER(checker, name) \
313 template<class C, typename T, typename = void> struct checker : std::false_type {}; \
314 template<class C, typename T> struct checker<C, T, typename std::enable_if< \
315 std::is_convertible<decltype(C::name), T>::value>::type> : std::true_type {}
318 #define MTYPE_CHECKER_STRICT(checker, name) \
319 template<class C, typename T, typename = void> struct checker : std::false_type {}; \
320 template<class C, typename T> struct checker<C, T, typename std::enable_if< \
321 std::is_same<decltype(C::name), T>::value>::type> : std::true_type {}
324 #define MTYPE_CHECKER_ANY(checker, name) \
325 template<class C, typename = void> struct checker : std::false_type {}; \
326 template<class C> struct checker<C, typename std::enable_if< \
327 !std::is_same<decltype(C::name)*, void>::value>::type> : std::true_type {}
330 #define METHOD_CHECKER(checker, name, ret, args) \
331 template<class C, typename=void> struct checker : std::false_type {}; \
332 template<class C> struct checker<C, typename std::enable_if< \
333 std::is_convertible<decltype(std::declval<C>().name args), ret>::value>::type> : std::true_type {};
336 #define METHOD_CHECKER_STRICT_RET(name, fn, ret, args) \
337 template<class C, typename=void> struct name : std::false_type {}; \
338 template<class C> struct name<C, typename std::enable_if< \
339 std::is_same<decltype(std::declval<C>().fn args), ret>::value>::type> : std::true_type {};
342 #define METHOD_CHECKER_ANY(name, fn, args) \
343 template<class C, typename=void> struct name : std::false_type {}; \
344 template<class C> struct name<C, typename std::enable_if< \
345 !std::is_same<decltype(std::declval<C>().fn args)*, void>::value>::type> : std::true_type {};
348 template <typename _Tp> inline constexpr
bool has_toString_v = has_toString<_Tp>::value;
351 template <typename _Tp> inline constexpr
bool has_to_string_v = has_to_string<_Tp>::value;
358 std::is_pointer<decltype(std::declval<C>().operator->())>::value>::type> : std::true_type {};
std::string to_string(const endian_t v) noexcept
Return std::string representation of the given endian.
constexpr bool isTypeTraitBitSet(const TypeTraitGroup mask, const TypeTraitGroup bit) noexcept
constexpr bool has_toString_v
constexpr TypeTraitGroup operator&(const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
constexpr bool has_member_of_pointer_v
constexpr bool has_to_string_v
constexpr bool is_container_memmove_compliant_v
constexpr bool is_enforcing_secmem_v
#define METHOD_CHECKER(checker, name, ret, args)
Checker for member function with convertible return type and accepting given arguments.
TypeTraitGroup
Enumerating the different groups of type traits.
constexpr TypeTraitGroup operator^(const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
constexpr TypeTraitGroup operator|(const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
@ SUPPORTED_OPERATIONS
SUPPORTED_OPERATIONS.
@ PRIMARY_TYPE_CAT
PRIMARY_TYPE_CAT.
@ TYPE_PROPERTIES
TYPE_PROPERTIES.
@ COMPOSITE_TYPE_CAT
COMPOSITE_TYPE_CAT.
constexpr uint32_t number(const func::target_type rhs) noexcept
__pack(...): Produces MSVC, clang and gcc compatible lead-in and -out macros.
bool operator==(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
bool operator!=(const callocator< T1 > &lhs, const callocator< T2 > &rhs) noexcept
Checker for member of pointer '->' operator with convertible pointer return, no arguments.
template< class T > is_container_memmove_compliant<T>::value compile-time Type Trait,...
template< class T > is_enforcing_secmem<T>::value compile-time Type Trait, determining whether the gi...
Helper, allowing simple access to compile time typename and Type traits information,...
static void print(const std::string &typedefname, const TypeTraitGroup verbosity=TypeTraitGroup::NONE)
Print information of this type to stdout, potentially with all Type traits known.
Helper, allowing simple access and provision of a typename string representation at compile time,...
static const char * name()
Return the string representation of this type.
int printf(const char *format,...)
Operating Systems predefined macros.