jaulib v1.3.0
Jau Support Library (C++, Java, ..)
|
Generic type information using either Runtime type information (RTTI) or Compile time type information (CTTI) More...
#include <cpp_lang_util.hpp>
Public Member Functions | |
type_info () noexcept | |
Constructor for an empty type_info instance, i.e. More... | |
type_info (const char *signature_) noexcept | |
Constructor using a const char* signature with a static storage duration. More... | |
type_info (const std::type_info &info_) noexcept | |
Constructor using an RTTI std::type_info reference, i.e. More... | |
std::string | demangled_name () const noexcept |
Return the demangle_name() of name(). More... | |
size_t | hash_code () const noexcept |
Returns an unspecified hash code of this instance. More... | |
const char * | name () const noexcept |
Returns the type name, compiler implementation specific. More... | |
bool | operator!= (const type_info &rhs) const noexcept |
constexpr bool | operator== (const type_info &rhs) const noexcept |
Return true if both instances are equal. More... | |
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. More... | |
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. More... | |
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. More... | |
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 435 of file cpp_lang_util.hpp.
|
inlinenoexcept |
Constructor for an empty type_info instance, i.e.
empty name() signature.
Definition at line 486 of file cpp_lang_util.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 500 of file cpp_lang_util.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 513 of file cpp_lang_util.hpp.
|
inlinestaticconstexprnoexcept |
Returns true if given signature is not nullptr and has a string length > 0, otherwise false.
Definition at line 468 of file cpp_lang_util.hpp.
|
inlinestaticnoexcept |
Aborts program execution if given signature is nullptr or has a string length == 0.
Definition at line 473 of file cpp_lang_util.hpp.
|
inlineconstexprnoexcept |
Return true if both instances are equal.
rhs |
Definition at line 524 of file cpp_lang_util.hpp.
|
inlinenoexcept |
Definition at line 535 of file cpp_lang_util.hpp.
|
inlinenoexcept |
Returns an unspecified hash code of this instance.
Compatible with std::type_info definition.
Definition at line 551 of file cpp_lang_util.hpp.
|
inlinenoexcept |
Returns the type name, compiler implementation specific.
Definition at line 554 of file cpp_lang_util.hpp.
|
inlinenoexcept |
Return the demangle_name() of name().
Definition at line 558 of file cpp_lang_util.hpp.
|
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 454 of file cpp_lang_util.hpp.