jaulib v1.3.8
Jau Support Library (C++, Java, ..)
|
Generic type information using either Runtime type information (RTTI) or Compile time type information (CTTI) More...
#include <type_info.hpp>
Public Member Functions | |
type_info () noexcept | |
Constructor for an empty type_info instance, i.e. | |
type_info (const char *signature_, bool identity_instance=false, bool identity_signature=false) noexcept | |
Constructor using a const char* signature with a static storage duration. | |
type_info (const std::type_info &info_, bool identity_instance=false) noexcept | |
Constructor using an RTTI std::type_info reference, i.e. | |
constexpr size_t | hash_code () const noexcept |
Returns an unspecified hash code of this instance. | |
constexpr bool | identInst () const noexcept |
Returns true if this instance has a unique address (for same type_info). | |
constexpr bool | identName () const noexcept |
Returns true if internal_name() has a unique identity address (for same signature strings). | |
constexpr const char * | internal_name () const noexcept |
Returns the type name, compiler implementation specific. | |
std::string | name () const noexcept |
Returns the demangled name of internal_name(). | |
bool | operator!= (const type_info &rhs) const noexcept |
constexpr bool | operator== (const type_info &rhs) const noexcept |
Return true if both instances are equal. | |
std::string | toString () const noexcept |
Static Public Member Functions | |
static void | abort_invalid (const char *signature) noexcept |
Aborts program execution if given signature is nullptr or has a string length == 0. | |
static constexpr bool | is_valid (const char *signature) noexcept |
Returns true if given signature is not nullptr and has a string length > 0, otherwise false. | |
Static Public Attributes | |
static constexpr const bool | limited_lambda_id |
Static constexpr boolean indicating whether resulting type_info uniqueness is limited for lambda function types. | |
Generic type information using either Runtime type information (RTTI) or Compile time type information (CTTI)
jau::type_info exposes same properties as RTTI std::type_index, i.e. can be used as index in associative and unordered associative containers and is CopyConstructible and CopyAssignable.
jau::type_info is compatible with std::type_index operations.
jau::type_info can be utilized w/o RTTI using Compile time type information (CTTI) information, i.e. JAU_PRETTY_FUNCTION via jau::ctti_name<R, L, A...>().
Consider using jau::make_ctti<R, L, A...>() for construction, as it removes the RTTI and CTTI code path differences.
If RTTI is being used, see cxx_rtti_available, jau::type_info may be instantiated with a std::type_info reference as returned from typeid(T).
Without RTTI jau::type_info may be instantiated using JAU_PRETTY_FUNCTION. Hence utilizes Compile time type information (CTTI) only.
In both cases, jau::type_info will solely operate on the const char* signature
and its hash value, aligning memory footprint and operations.
Use jau::make_ctti<R, L, A...>() for construction, as it removes the RTTI and CTTI code path differences.
We assume block scope and static storage duration (runtime lifecycle) of
true
if equal (fast path)false
if not matching (fast path)strcmp()
equality)gcc
or non clang
compilerDue to limitations of jau::make_ctti<R, L, A...>(), 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.
Definition at line 224 of file type_info.hpp.
|
inlinenoexcept |
Constructor for an empty type_info instance, i.e.
empty name() signature.
Definition at line 276 of file type_info.hpp.
|
inlinenoexcept |
Constructor using an RTTI std::type_info reference, i.e.
typeid(T) result.
Consider using jau::make_ctti<R, L, A...>() for construction, as it removes the RTTI and CTTI code path differences.
info_ | RTTI std::type_info reference |
Definition at line 291 of file type_info.hpp.
|
inlinenoexcept |
Constructor using a const char*
signature with a static storage duration.
Aborts program execution if given signature is nullptr or has a string length == 0.
signature_ | valid string signature of type with length > 0 with static storage duration. |
Definition at line 305 of file type_info.hpp.
|
inlinestaticconstexprnoexcept |
Returns true if given signature is not nullptr and has a string length > 0, otherwise false.
Definition at line 258 of file type_info.hpp.
|
inlinestaticnoexcept |
Aborts program execution if given signature is nullptr or has a string length == 0.
Definition at line 263 of file type_info.hpp.
|
inlineconstexprnoexcept |
Return true if both instances are equal.
rhs |
Definition at line 322 of file type_info.hpp.
|
inlinenoexcept |
Definition at line 336 of file type_info.hpp.
|
inlineconstexprnoexcept |
Returns an unspecified hash code of this instance.
Compatible with std::type_info definition.
Definition at line 352 of file type_info.hpp.
|
inlineconstexprnoexcept |
Returns true if this instance has a unique address (for same type_info).
Definition at line 355 of file type_info.hpp.
|
inlineconstexprnoexcept |
Returns true if internal_name() has a unique identity address (for same signature strings).
Definition at line 358 of file type_info.hpp.
|
inlineconstexprnoexcept |
Returns the type name, compiler implementation specific.
Definition at line 361 of file type_info.hpp.
|
inlinenoexcept |
Returns the demangled name of internal_name().
Definition at line 365 of file type_info.hpp.
|
noexcept |
Definition at line 919 of file basic_types.cpp.
|
staticconstexpr |
Static constexpr boolean indicating whether resulting type_info uniqueness is limited for lambda function types.
Always is false
if rtti_available == true
, i.e. lambda function types are always unique using RTTI.
May return true
if:
gcc
clang
Definition at line 244 of file type_info.hpp.