Direct-BT v3.3.0-1-gc2d430c
Direct-BT - Direct Bluetooth Programming.
Namespaces | Classes | Macros | Enumerations | Functions | Variables
C++ Language Utilities

C++ language utilities, language feature alignment, type trails, data alignment and intrinsics. More...

Collaboration diagram for C++ Language Utilities:

Namespaces

namespace  jau::impl
 

Classes

struct  jau::has_builtin_bit_cast< Dummy_type >
 Convenience type trait for __has_builtin(__builtin_bit_cast). More...
 
struct  jau::has_member_of_pointer< C, typename >
 Checker for member of pointer '->' operator with convertible pointer return, no arguments. More...
 
struct  jau::has_member_of_pointer< C, typename std::enable_if< std::is_pointer< decltype(std::declval< C >().operator->())>::value >::type >
 
struct  jau::is_container_memmove_compliant< class, class >
 template< class T > is_container_memmove_compliant<T>::value compile-time Type Trait, determining whether the given template class claims to be container memmove compliant, see @Ref darray_memmove. More...
 
struct  jau::is_container_memmove_compliant< T, std::void_t< typename T::container_memmove_compliant > >
 template< class T > is_container_memmove_compliant<T>::value compile-time Type Trait, determining whether the given template class claims to be container memmove compliant, see @Ref darray_memmove. More...
 
struct  jau::is_enforcing_secmem< class, class >
 template< class T > is_enforcing_secmem<T>::value compile-time Type Trait, determining whether the given template class enforces secmem, see @Ref darray_secmem. More...
 
struct  jau::is_enforcing_secmem< T, std::void_t< typename T::enforce_secmem > >
 template< class T > is_enforcing_secmem<T>::value compile-time Type Trait, determining whether the given template class enforces secmem, see @Ref darray_secmem. More...
 
struct  jau::is_rtti_available_t< _Dummy >
 Template type trait evaluating std::true_type{} if RTTI is available, otherwise std::false_type{}. More...
 
struct  jau::packed_t< T >
 Support aligned memory transfer from and to potentially unaligned memory. More...
 
struct  jau::type_cue< T >
 Helper, allowing simple access to compile time typename and Type traits information, see jau::type_name_cue to setup typename's string representation. More...
 
class  jau::type_info
 Generic type information using either Runtime type information (RTTI) or Compile time type information (CTTI) More...
 
struct  jau::type_name_cue< T >
 Helper, allowing simple access and provision of a typename string representation at compile time, see jau::type_cue for usage. More...
 

Macros

#define __builtin_bit_cast(Dest_type, Value_arg)   0
 Dummy definition in the absence of this builtin function as required to have this compilation unit compile clean. More...
 
#define __packed   __attribute__ ((packed))
 packed: lead out macro, requires packed lead in as well. More...
 
#define __restrict_cxx__
 Wrap C++ extension __restrict__ covering C99's restrict feature keyword. More...
 
#define consteval_cxx20   constexpr
 consteval qualifier replacement for C++20 consteval. More...
 
#define constexpr_atomic   inline
 Used when designed to declare a function constexpr, but prohibited by its specific implementation. More...
 
#define constexpr_cxx20   inline
 constexpr qualifier replacement for C++20 constexpr. More...
 
#define constexpr_cxx23   inline
 
#define constexpr_cxx26   inline
 
#define constexpr_non_literal_var   inline
 Used when designed to declare a function constexpr, but prohibited by its specific implementation. More...
 
#define constinit_cxx20   constexpr
 constinit qualifier replacement for C++20 constinit. More...
 
#define JAU_TYPENAME_CUE(A)   template<> struct jau::type_name_cue<A> { static const char * name() { return #A; } };
 
#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&)
 
#define METHOD_CHECKER(checker, name, ret, args)
 Checker for member function with convertible return type and accepting given arguments. More...
 
#define METHOD_CHECKER_ANY(name, fn, args)
 Checker for member function accepting given arguments. More...
 
#define METHOD_CHECKER_STRICT_RET(name, fn, ret, args)
 Checker for member function with exact retutn type and accepting given arguments. More...
 
#define MTYPE_CHECKER(checker, name)
 Checker for member with given name and convertible type. More...
 
#define MTYPE_CHECKER_ANY(checker, name)
 Checker for member with given name and any type. More...
 
#define MTYPE_CHECKER_STRICT(checker, name)
 Checker for member with given name and exact type. More...
 
#define packed__
 packed__: lead in macro, requires __packed lead out as well. More...
 
#define PRAGMA_DISABLE_WARNING_CPP
 
#define PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL
 
#define PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW
 
#define PRAGMA_DISABLE_WARNING_MULTICHAR
 
#define PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE
 
#define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS
 
#define PRAGMA_DISABLE_WARNING_POP
 
#define PRAGMA_DISABLE_WARNING_PUSH
 
#define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW
 
#define PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER
 
#define PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION
 

Enumerations

enum class  jau::TypeTraitGroup : uint8_t {
  jau::TypeTraitGroup::NONE = 0b00000000 , jau::TypeTraitGroup::PRIMARY_TYPE_CAT = 0b00000001 , jau::TypeTraitGroup::TYPE_PROPERTIES = 0b00000010 , jau::TypeTraitGroup::COMPOSITE_TYPE_CAT = 0b00000100 ,
  jau::TypeTraitGroup::SUPPORTED_OPERATIONS = 0b00001000 , jau::TypeTraitGroup::ALL = 0b11111111
}
 Enumerating the different groups of type traits. More...
 

Functions

template<class Dest , class Source >
constexpr std::enable_if_t< sizeof(Dest)==sizeof(Source) &&std::is_trivially_copyable_v< Dest > &&std::is_trivially_copyable_v< Source >, Dest > jau::bit_cast (const Source &src) noexcept
 C++20 bit_cast<>(arg) implementation for C++17. More...
 
template<typename T >
constexpr const char * jau::ctti_name () noexcept
 Returns the type name of given type T using template Compile Time Type Information (CTTI) only with static constant storage duration. More...
 
template<typename R , typename L , typename... A>
constexpr const char * jau::ctti_name () noexcept
 Returns the type name of given function types R(*L)(A...) using template Compile Time Type Information (CTTI) only with static constant storage duration. More...
 
std::string jau::demangle_name (const char *mangled_name) noexcept
 Returns the demangled given mangled_name if successful, otherwise the mangled_name. More...
 
consteval_cxx20 bool jau::is_builtin_bit_cast_available () noexcept
 Query whether __builtin_bit_cast(Dest_type, arg) is available, using jau::has_builtin_bit_cast. More...
 
consteval_cxx20 bool jau::is_builtin_int128_available () noexcept
 
consteval_cxx20 bool jau::is_cxx17 () noexcept
 Returns true if compiled with >= C++17. More...
 
consteval_cxx20 bool jau::is_cxx20 () noexcept
 Returns true if compiled with >= C++20. More...
 
consteval_cxx20 bool jau::is_cxx23 () noexcept
 Returns true if compiled with >= C++23. More...
 
consteval_cxx20 bool jau::is_cxx26 () noexcept
 Returns true if compiled with >= C++26. More...
 
consteval_cxx20 bool jau::is_debug_enabled () noexcept
 Returns true if compiled with debug information and w/o optimization, i.e. More...
 
consteval_cxx20 bool jau::is_rtti_available () noexcept
 Returns true if compiled with RTTI available. More...
 
constexpr bool jau::isTypeTraitBitSet (const TypeTraitGroup mask, const TypeTraitGroup bit) noexcept
 
template<typename T >
jau::type_info jau::make_ctti () noexcept
 Constructs a jau::type_info instance based on given type T using template Compile Time Type Information (CTTI) only. More...
 
template<typename R , typename L , typename... A>
jau::type_info jau::make_ctti () noexcept
 Constructs a jau::type_info instance based on given function types R(*L)(A...) using template Compile Time Type Information (CTTI) only via RTTI's `typeid(L) if available or jau::ctti_name<R, L, A...>() otherwise. More...
 
constexpr uint8_t jau::number (const TypeTraitGroup rhs) noexcept
 
constexpr bool jau::operator!= (const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
 
constexpr TypeTraitGroup jau::operator& (const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
 
constexpr bool jau::operator== (const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
 
constexpr TypeTraitGroup jau::operator^ (const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
 
constexpr TypeTraitGroup jau::operator| (const TypeTraitGroup lhs, const TypeTraitGroup rhs) noexcept
 
template<class Dest , class Source >
constexpr std::enable_if_t< sizeof(Dest)==sizeof(Source) &&std::is_pointer_v< Source > &&std::is_pointer_v< Dest >, Dest > jau::pointer_cast (const Source &src) noexcept
 A constexpr pointer cast implementation for C++17, inspired by C++20 bit_cast<>(arg). More...
 
template<typename T >
const char * jau::type_name () noexcept
 Returns the type name of given type T using template Compile Time Type Information (CTTI) only via RTTI's typeid(T).name() if available or jau::ctti_name<T>() otherwise. More...
 
template<typename R , typename L , typename... A>
const char * jau::type_name () noexcept
 Returns the type name of given function types R(*L)(A...) using template Compile Time Type Information (CTTI) only via RTTI's typeid(L).name() if available or jau::ctti_name<R, L, A...>() otherwise. More...
 

Variables

template<typename Dummy_type >
constexpr bool jau::has_builtin_bit_cast_v = has_builtin_bit_cast<Dummy_type>::value
 Value access of has_builtin_bit_cast type trait for convenience . More...
 
template<typename _Tp >
constexpr bool jau::has_member_of_pointer_v = has_member_of_pointer<_Tp>::value
 
template<typename _Tp >
constexpr bool jau::has_to_string_v = has_to_string<_Tp>::value
 
template<typename _Tp >
constexpr bool jau::has_toString_v = has_toString<_Tp>::value
 
template<typename T >
constexpr bool jau::is_container_memmove_compliant_v = is_container_memmove_compliant<T>::value
 
template<typename T >
constexpr bool jau::is_enforcing_secmem_v = is_enforcing_secmem<T>::value
 
template<typename _Dummy >
constexpr bool jau::is_rtti_available_v = is_rtti_available_t<_Dummy>::value
 Template type trait helper evaluating true if RTTI is available, otherwise false. More...
 

Detailed Description

C++ language utilities, language feature alignment, type trails, data alignment and intrinsics.

Used predefined __cplusplus macro identifier for C++ language specs:

Used predefined macros denoting the compiler:

Further infos:

Macro Definition Documentation

◆ consteval_cxx20

#define consteval_cxx20   constexpr

consteval qualifier replacement for C++20 consteval.

‍A consteval specifier implies inline. At most one of the constexpr, consteval, and constinit specifiers is allowed to appear within the same sequence of declaration specifiers. ... An immediate function is a constexpr function, and must satisfy the requirements applicable to constexpr functions or constexpr constructors, as the case may be.

Evaluated using the alternative qualifier constexpr for C++ < 20, as it is almost contained within consteval but lacks the immediate function constraint.

Evaluated as consteval for C++20.

Definition at line 84 of file cpp_lang_util.hpp.

◆ constinit_cxx20

#define constinit_cxx20   constexpr

constinit qualifier replacement for C++20 constinit.

constinit cannot be used together with constexpr or consteval. When the declared variable is a reference, constinit is equivalent to constexpr. When the declared variable is an object, constexpr mandates that the object must have static initialization and constant destruction and makes the object const-qualified, however, constinit does not mandate constant destruction and const-qualification.

Evaluated using the alternative qualifier constexpr for C++ < 20, as it is almost contained within constinit but lacks the loosening of not mandating constant destruction and const-qualification.
FIXME: Due to the above, this replacement might not be suitable: TBD!

Evaluated as constinit for C++20.

Definition at line 141 of file cpp_lang_util.hpp.

◆ constexpr_cxx20

#define constexpr_cxx20   inline

constexpr qualifier replacement for C++20 constexpr.

‍A constexpr specifier used in a function or static member variable (since C++17) declaration implies inline.

Evaluated using the alternative qualifier inline for C++ < 20, as it is implied for constexpr functions or static member variables, see above.

Evaluated as constexpr for C++20, i.e. std::string literals, virtual functions, etc.

Definition at line 160 of file cpp_lang_util.hpp.

◆ constexpr_cxx23

#define constexpr_cxx23   inline

Definition at line 166 of file cpp_lang_util.hpp.

◆ constexpr_cxx26

#define constexpr_cxx26   inline

Definition at line 172 of file cpp_lang_util.hpp.

◆ constexpr_non_literal_var

#define constexpr_non_literal_var   inline

Used when designed to declare a function constexpr, but prohibited by its specific implementation.

Evaluated using the alternative qualifier inline for C++ < 20, as it is implied for constexpr functions or static member variables, see constexpr_cxx20.

Here it but uses non-literal variables, such as std::lock_guard etc. As these can't be evaluated at compile time, the standard does not allow using constexpr here.

Empty until standard defines otherwise.

See also
constexpr_cxx20

Definition at line 193 of file cpp_lang_util.hpp.

◆ constexpr_atomic

#define constexpr_atomic   inline

Used when designed to declare a function constexpr, but prohibited by its specific implementation.

Evaluated using the alternative qualifier inline for C++ < 20, as it is implied for constexpr functions or static member variables, see constexpr_cxx20.

Here it uses thread-safety related measures like atomic storage or mutex locks, which are non-literal variables and hence prohibit the use of constexpr.

See also
constexpr_cxx20
constexpr_non_literal_var

Definition at line 210 of file cpp_lang_util.hpp.

◆ __restrict_cxx__

#define __restrict_cxx__

Wrap C++ extension __restrict__ covering C99's restrict feature keyword.

Definition at line 222 of file cpp_lang_util.hpp.

◆ __builtin_bit_cast

#define __builtin_bit_cast (   Dest_type,
  Value_arg 
)    0

Dummy definition in the absence of this builtin function as required to have this compilation unit compile clean.

Parameters
Dest_typethe target type
Value_argthe source value argument

Definition at line 687 of file cpp_lang_util.hpp.

◆ PRAGMA_DISABLE_WARNING_PUSH

#define PRAGMA_DISABLE_WARNING_PUSH

Definition at line 76 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_POP

#define PRAGMA_DISABLE_WARNING_POP

Definition at line 77 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER

#define PRAGMA_DISABLE_WARNING_UNREFERENCED_FORMAL_PARAMETER

Definition at line 78 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION

#define PRAGMA_DISABLE_WARNING_UNREFERENCED_FUNCTION

Definition at line 79 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_CPP

#define PRAGMA_DISABLE_WARNING_CPP

Definition at line 80 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_MULTICHAR

#define PRAGMA_DISABLE_WARNING_MULTICHAR

Definition at line 81 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE

#define PRAGMA_DISABLE_WARNING_NULL_DEREFERENCE

Definition at line 82 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW

#define PRAGMA_DISABLE_WARNING_FORMAT_OVERFLOW

Definition at line 83 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL

#define PRAGMA_DISABLE_WARNING_FORMAT_NONLITERAL

Definition at line 84 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS

#define PRAGMA_DISABLE_WARNING_PMF_CONVERSIONS

Definition at line 85 of file cpp_pragma.hpp.

◆ PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW

#define PRAGMA_DISABLE_WARNING_STRINGOP_OVERFLOW

Definition at line 86 of file cpp_pragma.hpp.

◆ packed__

#define packed__

packed__: lead in macro, requires __packed lead out as well.

Consider using __pack(...).

Definition at line 39 of file packed_attribute.hpp.

◆ __packed

#define __packed   __attribute__ ((packed))

packed: lead out macro, requires packed lead in as well.

Consider using __pack(...).

Definition at line 48 of file packed_attribute.hpp.

◆ JAU_TYPENAME_CUE

#define JAU_TYPENAME_CUE (   A)    template<> struct jau::type_name_cue<A> { static const char * name() { return #A; } };

Definition at line 228 of file type_traits_queries.hpp.

◆ JAU_TYPENAME_CUE_ALL

#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&)
Examples
test_cow_iterator_01.cpp.

Definition at line 229 of file type_traits_queries.hpp.

◆ MTYPE_CHECKER

#define MTYPE_CHECKER (   checker,
  name 
)
Value:
template<class C, typename T, typename = void> struct checker : std::false_type {}; \
template<class C, typename T> struct checker<C, T, typename std::enable_if< \
std::is_convertible<decltype(C::name), T>::value>::type> : std::true_type {}
STL namespace.

Checker for member with given name and convertible type.

Definition at line 312 of file type_traits_queries.hpp.

◆ MTYPE_CHECKER_STRICT

#define MTYPE_CHECKER_STRICT (   checker,
  name 
)
Value:
template<class C, typename T, typename = void> struct checker : std::false_type {}; \
template<class C, typename T> struct checker<C, T, typename std::enable_if< \
std::is_same<decltype(C::name), T>::value>::type> : std::true_type {}

Checker for member with given name and exact type.

Definition at line 318 of file type_traits_queries.hpp.

◆ MTYPE_CHECKER_ANY

#define MTYPE_CHECKER_ANY (   checker,
  name 
)
Value:
template<class C, typename = void> struct checker : std::false_type {}; \
template<class C> struct checker<C, typename std::enable_if< \
!std::is_same<decltype(C::name)*, void>::value>::type> : std::true_type {}

Checker for member with given name and any type.

Definition at line 324 of file type_traits_queries.hpp.

◆ METHOD_CHECKER

#define METHOD_CHECKER (   checker,
  name,
  ret,
  args 
)
Value:
template<class C, typename=void> struct checker : std::false_type {}; \
template<class C> struct checker<C, typename std::enable_if< \
std::is_convertible<decltype(std::declval<C>().name args), ret>::value>::type> : std::true_type {};

Checker for member function with convertible return type and accepting given arguments.

Definition at line 330 of file type_traits_queries.hpp.

◆ METHOD_CHECKER_STRICT_RET

#define METHOD_CHECKER_STRICT_RET (   name,
  fn,
  ret,
  args 
)
Value:
template<class C, typename=void> struct name : std::false_type {}; \
template<class C> struct name<C, typename std::enable_if< \
std::is_same<decltype(std::declval<C>().fn args), ret>::value>::type> : std::true_type {};

Checker for member function with exact retutn type and accepting given arguments.

Examples
test_type_traits_queries01.cpp.

Definition at line 336 of file type_traits_queries.hpp.

◆ METHOD_CHECKER_ANY

#define METHOD_CHECKER_ANY (   name,
  fn,
  args 
)
Value:
template<class C, typename=void> struct name : std::false_type {}; \
template<class C> struct name<C, typename std::enable_if< \
!std::is_same<decltype(std::declval<C>().fn args)*, void>::value>::type> : std::true_type {};

Checker for member function accepting given arguments.

Definition at line 342 of file type_traits_queries.hpp.

Enumeration Type Documentation

◆ TypeTraitGroup

enum class jau::TypeTraitGroup : uint8_t
strong

Enumerating the different groups of type traits.

Enumerator
NONE 

NONE.

PRIMARY_TYPE_CAT 

PRIMARY_TYPE_CAT.

TYPE_PROPERTIES 

TYPE_PROPERTIES.

COMPOSITE_TYPE_CAT 

COMPOSITE_TYPE_CAT.

SUPPORTED_OPERATIONS 

SUPPORTED_OPERATIONS.

ALL 

ALL.

Definition at line 50 of file type_traits_queries.hpp.

Function Documentation

◆ is_cxx17()

consteval_cxx20 bool jau::is_cxx17 ( )
noexcept

Returns true if compiled with >= C++17.

Definition at line 88 of file cpp_lang_util.hpp.

◆ is_cxx20()

consteval_cxx20 bool jau::is_cxx20 ( )
noexcept

Returns true if compiled with >= C++20.

Definition at line 96 of file cpp_lang_util.hpp.

◆ is_cxx23()

consteval_cxx20 bool jau::is_cxx23 ( )
noexcept

Returns true if compiled with >= C++23.

Definition at line 104 of file cpp_lang_util.hpp.

◆ is_cxx26()

consteval_cxx20 bool jau::is_cxx26 ( )
noexcept

Returns true if compiled with >= C++26.

Definition at line 112 of file cpp_lang_util.hpp.

◆ is_rtti_available()

consteval_cxx20 bool jau::is_rtti_available ( )
noexcept

Returns true if compiled with RTTI available.

Examples
test_functional.hpp, and test_functional_perf.hpp.

Definition at line 274 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ ctti_name() [1/2]

template<typename T >
constexpr const char * jau::ctti_name ( )
constexprnoexcept

Returns the type name of given type T using template Compile Time Type Information (CTTI) only with static constant storage duration.

Template Parameters
Tthe type
Returns
instance of jau::type_info
See also
jau::make_ctti<T>
ctti_name_lambda
Examples
test_functional.hpp.

Definition at line 307 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ ctti_name() [2/2]

template<typename R , typename L , typename... A>
constexpr const char * jau::ctti_name ( )
constexprnoexcept

Returns the type name of given function types R(*L)(A...) using template Compile Time Type Information (CTTI) only with static constant storage duration.

Limitations

Non unique function pointer type names with same prototype

With RTTI or wihout, c-alike function pointer type names like int(*)(int) do not expose their source location like lambda functions do. Hence they can't be used to compare code identity, but lambda functions can be used.

Non unique lambda type names without RTTI using gcc or non clang compiler

Due to the lack of standardized Compile-Time Type Information (CTTI), we rely on the non-standardized macro extensions

  • __PRETTY_FUNCTION__
    • clang produces a unique tag using filename and line number, compatible.
    • gcc produces a non-unique tag using the parent function of the lambda location and its too brief signature, not fully compatible.
  • __FUNCSIG__
    • msvc++ not tested
  • Any other compiler is not supported yet

Due to these restrictions, not using RTTI on gcc or non clang compiler will erroneously mistake different lambda functions defined within one function and using same function prototype R<A...> to be the same.

jau::type_info::limited_lambda_id exposes the potential limitation.

Template Parameters
Rfunction return type
Lmain function type, e.g. a lambda type.
Afunction argument types
Returns
instance of jau::type_info
See also
jau::make_ctti<R, L, A...>
ctti_name_type
jau::type_info::limited_lambda_id

Definition at line 349 of file cpp_lang_util.hpp.

◆ demangle_name()

std::string jau::demangle_name ( const char *  mangled_name)
noexcept

Returns the demangled given mangled_name if successful, otherwise the mangled_name.

Implementation utilizes the cross-vendor C++ ABI abi::__cxa_demangle() as supported at least on on gcc and clang.

May be used to demangle the result of jau::type_name() or jau::type_info::name() if jau::type_info::rtti_available == true, i.e. RTTI typeif(T) symbols are being used.

See also gcc libstdc++ FAQ, Chapter 28.

Further, implementation also checks whether the mangled_name results from jau::ctti_name<T>() and cleans up the known gcc and clang variant of JAU_PRETTY_FUNCTION.

Parameters
mangled_namemangled name

Definition at line 57 of file debug.cpp.

Here is the caller graph for this function:

◆ make_ctti() [1/2]

template<typename T >
jau::type_info jau::make_ctti ( )
noexcept

Constructs a jau::type_info instance based on given type T using template Compile Time Type Information (CTTI) only.

This construction function either uses typeid(T) if jau::type_info::rtti_available == true or jau::ctti_name<T>() otherwise.

Template Parameters
Ttype for which the type_info is generated
Returns
instance of jau::type_info
See also
jau::ctti_name<T>

Definition at line 576 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ make_ctti() [2/2]

template<typename R , typename L , typename... A>
jau::type_info jau::make_ctti ( )
noexcept

Constructs a jau::type_info instance based on given function types R(*L)(A...) using template Compile Time Type Information (CTTI) only via RTTI's `typeid(L) if available or jau::ctti_name<R, L, A...>() otherwise.

This construction function either uses typeid(L) if jau::type_info::rtti_available == true or jau::ctti_name<R, L, A...>() otherwise.

Template Parameters
Rfunction return type used for type_info in case of jau::type_info::rtti_available == false
Lmain function type for which the type_info is generated, e.g. a lambda type.
Afunction argument types used for type_info in case of jau::type_info::rtti_available == false
Returns
instance of jau::type_info
See also
jau::ctti_name<R, L, A...>

Definition at line 600 of file cpp_lang_util.hpp.

◆ type_name() [1/2]

template<typename T >
const char * jau::type_name ( )
noexcept

Returns the type name of given type T using template Compile Time Type Information (CTTI) only via RTTI's typeid(T).name() if available or jau::ctti_name<T>() otherwise.

Template Parameters
Ttype for which the type_info is generated
Returns
type name
See also
jau::ctti_name<T>

Definition at line 618 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ type_name() [2/2]

template<typename R , typename L , typename... A>
const char * jau::type_name ( )
noexcept

Returns the type name of given function types R(*L)(A...) using template Compile Time Type Information (CTTI) only via RTTI's typeid(L).name() if available or jau::ctti_name<R, L, A...>() otherwise.

Template Parameters
Rfunction return type used for type_info in case of jau::type_info::rtti_available == false
Lmain function type for which the type_info is generated, e.g. a lambda type.
Afunction argument types used for type_info in case of jau::type_info::rtti_available == false
Returns
type name
See also
jau::ctti_name<R, L, A...>

Definition at line 638 of file cpp_lang_util.hpp.

◆ is_builtin_bit_cast_available()

consteval_cxx20 bool jau::is_builtin_bit_cast_available ( )
noexcept

Query whether __builtin_bit_cast(Dest_type, arg) is available, using jau::has_builtin_bit_cast.


Availability of __builtin_bit_cast(Dest_type, arg)

Reflecting my manual platform tests using test_basictypeconv.cpp

Compiler Version Architecture Available
GCC 8.3.0 amd64, arm64, arm32 no
GCC 10.2.1 amd64 no
GCC 12.2.0 amd64 yes
clang 9.0.1 amd64, arm64 yes
clang 11.0.1 amd64 yes
Returns
true if query subject is available, otherwise not.
See also
has_builtin_bit_cast
bit_cast()
pointer_cast()
Examples
test_basictypeconv.cpp.

Definition at line 728 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ bit_cast()

template<class Dest , class Source >
constexpr std::enable_if_t< sizeof(Dest)==sizeof(Source) && std::is_trivially_copyable_v< Dest > && std::is_trivially_copyable_v< Source >, Dest > jau::bit_cast ( const Source &  src)
constexprnoexcept

C++20 bit_cast<>(arg) implementation for C++17.

Functional if is_builtin_bit_cast_available() evaluates true.

Template Parameters
Destthe target type
Sourcethe source argument type
Parameters
srcthe value to convert to Dest type
Returns
the converted Dest type value
See also
jau::has_builtin_bit_cast
is_builtin_bit_cast_available()
pointer_cast()

Definition at line 752 of file cpp_lang_util.hpp.

◆ pointer_cast()

template<class Dest , class Source >
constexpr std::enable_if_t< sizeof(Dest)==sizeof(Source) && std::is_pointer_v< Source > && std::is_pointer_v< Dest >, Dest > jau::pointer_cast ( const Source &  src)
constexprnoexcept

A constexpr pointer cast implementation for C++17, inspired by C++20 bit_cast<>(arg).

If is_builtin_bit_cast_available() evaluates true, implementation uses __builtin_bit_cast(Dest, src).

Otherwise a simple reinterpret_cast<Dest>(src) is utilized, which officially is questionable to deliver a constexpr.

Template Parameters
Destthe target pointer type
Sourcethe source pointer argument type
Parameters
srcthe pointer to convert to Dest pointer type
Returns
the converted Dest pointer type value
See also
jau::has_builtin_bit_cast
is_builtin_bit_cast_available()
bit_cast()

Definition at line 787 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ is_builtin_int128_available()

consteval_cxx20 bool jau::is_builtin_int128_available ( )
noexcept

Definition at line 797 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ is_debug_enabled()

consteval_cxx20 bool jau::is_debug_enabled ( )
noexcept

Returns true if compiled with debug information and w/o optimization, i.e.

not defined(NDEBUG) && !defined(DEBUG).

Definition at line 817 of file cpp_lang_util.hpp.

Here is the caller graph for this function:

◆ number()

constexpr uint8_t jau::number ( const TypeTraitGroup  rhs)
constexprnoexcept

Definition at line 58 of file type_traits_queries.hpp.

◆ operator^()

constexpr TypeTraitGroup jau::operator^ ( const TypeTraitGroup  lhs,
const TypeTraitGroup  rhs 
)
constexprnoexcept

Definition at line 61 of file type_traits_queries.hpp.

◆ operator|()

constexpr TypeTraitGroup jau::operator| ( const TypeTraitGroup  lhs,
const TypeTraitGroup  rhs 
)
constexprnoexcept

Definition at line 64 of file type_traits_queries.hpp.

◆ operator&()

constexpr TypeTraitGroup jau::operator& ( const TypeTraitGroup  lhs,
const TypeTraitGroup  rhs 
)
constexprnoexcept

Definition at line 67 of file type_traits_queries.hpp.

◆ operator==()

constexpr bool jau::operator== ( const TypeTraitGroup  lhs,
const TypeTraitGroup  rhs 
)
constexprnoexcept

Definition at line 70 of file type_traits_queries.hpp.

◆ operator!=()

constexpr bool jau::operator!= ( const TypeTraitGroup  lhs,
const TypeTraitGroup  rhs 
)
constexprnoexcept

Definition at line 73 of file type_traits_queries.hpp.

◆ isTypeTraitBitSet()

constexpr bool jau::isTypeTraitBitSet ( const TypeTraitGroup  mask,
const TypeTraitGroup  bit 
)
constexprnoexcept

Definition at line 76 of file type_traits_queries.hpp.

Here is the caller graph for this function:

Variable Documentation

◆ is_rtti_available_v

template<typename _Dummy >
constexpr bool jau::is_rtti_available_v = is_rtti_available_t<_Dummy>::value
inlineconstexpr

Template type trait helper evaluating true if RTTI is available, otherwise false.

Template Parameters
_Dummyunused dummy type to satisfy SFINAE

Definition at line 271 of file cpp_lang_util.hpp.

◆ has_builtin_bit_cast_v

template<typename Dummy_type >
constexpr bool jau::has_builtin_bit_cast_v = has_builtin_bit_cast<Dummy_type>::value
constexpr

Value access of has_builtin_bit_cast type trait for convenience .

Template Parameters
Dummy_typejust to make template SFINAE happy
See also
has_builtin_bit_cast

Definition at line 678 of file cpp_lang_util.hpp.

◆ is_container_memmove_compliant_v

template<typename T >
constexpr bool jau::is_container_memmove_compliant_v = is_container_memmove_compliant<T>::value
inlineconstexpr

Definition at line 253 of file type_traits_queries.hpp.

◆ is_enforcing_secmem_v

template<typename T >
constexpr bool jau::is_enforcing_secmem_v = is_enforcing_secmem<T>::value
inlineconstexpr

Definition at line 269 of file type_traits_queries.hpp.

◆ has_toString_v

template<typename _Tp >
constexpr bool jau::has_toString_v = has_toString<_Tp>::value
inlineconstexpr

Definition at line 348 of file type_traits_queries.hpp.

◆ has_to_string_v

template<typename _Tp >
constexpr bool jau::has_to_string_v = has_to_string<_Tp>::value
inlineconstexpr

Definition at line 351 of file type_traits_queries.hpp.

◆ has_member_of_pointer_v

template<typename _Tp >
constexpr bool jau::has_member_of_pointer_v = has_member_of_pointer<_Tp>::value
inlineconstexpr

Definition at line 360 of file type_traits_queries.hpp.