Lumiera
0.pre.03
»edit your freedom«
|
Go to the source code of this file.
Simple and lightweight helpers for metaprogramming and type detection.
This header is a collection of very basic type detection and metaprogramming utilities.
Definition in file meta/util.hpp.
#include "lib/integral.hpp"
#include <typeinfo>
#include <string>
Typedefs | |
template<class Cond , class T = void> | |
using | disable_if = typename enable_if_c< not Cond::value, T >::type |
template<class SELF , typename ... ARGS> | |
using | disable_if_self = disable_if< std::is_same< std::remove_cv_t< std::remove_reference_t< extractFirst_t< ARGS... > >>, SELF > > |
helper to prevent a template constructor from shadowing inherited copy ctors | |
template<typename X > | |
using | enable_CustomStringConversion = enable_if< can_convertToString< X > > |
toggle for explicit specialisations | |
template<class Cond , class T = void> | |
using | enable_if = typename enable_if_c< Cond::value, T >::type |
SFINAE helper to control the visibility of specialisations and overloads. More... | |
template<typename... XS> | |
using | extractFirst_t = typename _ExtractFirst< XS... >::Type |
helper to extract the first argument from a variadic arg pack, if any | |
typedef char | Yes_t |
helper types to detect the overload resolution chosen by the compiler | |
Functions | |
string | demangleCxx (Literal rawName) |
Fallback type-ID: More... | |
string | humanReadableTypeID (lib::Literal) |
pretty-print an internal C++ type representation More... | |
ullong | operator""_GiB (ullong const siz) |
uint | operator""_KiB (ullong const siz) |
uint | operator""_MiB (ullong const siz) |
string | primaryTypeComponent (lib::Literal) |
extract core name component from a raw type spec More... | |
string | sanitisedFullTypeName (lib::Literal) |
build a sanitised ID from full type name | |
string | sanitisedSymbol (std::string const &) |
condense a string and retain only valid identifiers More... | |
string | showAdr (void const *addr) noexcept |
pretty-print an address as hex-suffix | |
template<typename X > | |
lib::meta::disable_if< std::is_pointer< X >, std::string > | showAdr (X &elm) noexcept |
std::string | showBool (bool yes) noexcept |
human readable display of boolean values More... | |
string | showComplete (double) noexcept |
show enough decimal digits to represent every distinct value | |
string | showComplete (float val) noexcept |
string | showComplete (f128 val) noexcept |
string | showDecimal (double) noexcept |
show maximum reproducible decimal representation | |
string | showDecimal (float val) noexcept |
string | showDecimal (f128 val) noexcept |
string | showDouble (double) noexcept |
pretty-print a double in (rounded) fixed-point format More... | |
string | showFloat (float val) noexcept |
template<typename X > | |
std::string | showPtr (X *ptr=nullptr) |
diagnostics helper for explicitly indicating pointers | |
string | showSize (size_t val) noexcept |
template<typename SP > | |
std::string | showSmartPtr (SP const &smPtr, std::string label="smP") |
template<typename TY > | |
std::string | typeStr (TY const *obj=nullptr) noexcept |
failsafe human readable type display More... | |
template<typename TY > | |
disable_if< std::is_pointer< TY >, std::string > | typeStr (TY const &ref) noexcept |
std::string | typeStr (void const *) noexcept |
template<typename TY > | |
std::string | typeSymbol (TY const *obj=nullptr) |
simple expressive symbol to designate a type More... | |
template<typename TY > | |
disable_if< std::is_pointer< TY >, std::string > | typeSymbol (TY const &ref) |
Namespaces | |
lib | |
Implementation namespace for support and library code. | |
using enable_if = typename enable_if_c<Cond::value, T>::type |
SFINAE helper to control the visibility of specialisations and overloads.
Cond::value
holds true. In the typical usage, this condition is suppled by a metafunction, i.e. a template, which detects some feature or other circumstantial condition with the types involved. Definition at line 83 of file meta/util.hpp.
struct lib::meta::anonymous_namespace{util.hpp}::_ExtractFirst |
struct lib::meta::anonymous_namespace{util.hpp}::_ExtractFirst< X, XS... > |
struct lib::meta::has_FunctionOperator::Probe |
struct lib::meta::can_convertToString::Probe |
std::string humanReadableTypeID | ( | Literal | rawType | ) |
pretty-print an internal C++ type representation
const
, &
or *
, however, the typical usage from within util::typeStr() is arranged in a way to absorb these adornments by the way the template signatures are definedstd::regex_replace
Definition at line 190 of file format-obj.cpp.
References lib::meta::demangleCxx(), and lib::meta::humanReadableTypeID().
Referenced by lib::meta::humanReadableTypeID(), and lib::meta::sanitisedFullTypeName().
std::string primaryTypeComponent | ( | Literal | rawType | ) |
extract core name component from a raw type spec
::
Definition at line 268 of file format-obj.cpp.
References lib::meta::demangleCxx(), lib::meta::primaryTypeComponent(), and lib::meta::typeStr().
Referenced by lib::meta::primaryTypeComponent().
std::string sanitisedSymbol | ( | std::string const & | ) |
condense a string and retain only valid identifiers
Definition at line 313 of file format-obj.cpp.
References lib::meta::sanitisedSymbol().
Referenced by lib::meta::sanitisedSymbol().
std::string demangleCxx | ( | Literal | rawName | ) |
Fallback type-ID:
reverse the effect of C++ name mangling.
Definition at line 159 of file format-obj.cpp.
References lib::meta::demangleCxx().
Referenced by lib::meta::demangleCxx(), lib::meta::humanReadableTypeID(), and lib::meta::primaryTypeComponent().
|
inlinenoexcept |
failsafe human readable type display
const
, *
and &
const&
variant of this function, since C++ considers this best match in template substitution. Thus, we deliberately force calls with pointer to enter here, since we do want the pointer itself (and not a pointer to the pointer). We then pass the "object" as so called "glvalue" to the typeid()
function, so to get the evaluation of RTTI, when applicable. Definition at line 316 of file meta/util.hpp.
Referenced by lib::meta::primaryTypeComponent().
|
inline |
simple expressive symbol to designate a type
Definition at line 348 of file meta/util.hpp.
|
inlinenoexcept |
human readable display of boolean values
Definition at line 435 of file meta/util.hpp.
References util::showBool().
Referenced by util::showBool().
|
noexcept |
pretty-print a double in (rounded) fixed-point format
0.1
(which can not be represented as binary floats) Definition at line 360 of file format-obj.cpp.
References util::showDouble().
Referenced by util::showDouble().