Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
util.hpp File Reference

Simple and lightweight helpers for metaprogramming and type detection. More...

Go to the source code of this file.

Description

Simple and lightweight helpers for metaprogramming and type detection.

This header is a collection of very basic type detection and metaprogramming utilities.

Warning
indirectly, this header gets included into the majority of compilation units. Avoid anything here which increases compilation times or adds much debugging info.
See also
MetaUtils_test
trait.hpp
typelist.hpp

Definition in file meta/util.hpp.

#include "lib/integral.hpp"
#include <typeinfo>
#include <string>

Namespaces

namespace  std
 STL namespace.
 
namespace  lib
 Implementation namespace for support and library code.
 
namespace  lib::meta
 
namespace  lib::meta::anonymous_namespace{util.hpp}
 
namespace  util
 

Typedefs

template<size_t siz>
using SizConst = std::integral_constant< size_t, siz >
 
template<class Cond , class T = void>
using enable_if = enable_if_c< Cond::value, T >::type
 SFINAE helper to control the visibility of specialisations and overloads.
 
template<class Cond , class T = void>
using disable_if = enable_if_c< not Cond::value, T >::type
 
typedef char Yes_t
 helper types to detect the overload resolution chosen by the compiler
 
template<typename... XS>
using extractFirst_t = _ExtractFirst< XS... >::Type
 helper to extract the first argument from a variadic arg pack, if any
 
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
 

Classes

struct  enable_if_c< B, T >
 
struct  enable_if_c< false, T >
 
struct  No_t
 
class  _DetectNested_TypeResult< TY >
 
struct  has_TypeResult< X >
 helper to check if another metafunction produced a result type More...
 
struct  _ExtractFirst<... >
 
struct  _ExtractFirst< X, XS... >
 
struct  can_convertToString< X >
 detect possibility of a conversion to string. More...
 
struct  can_convertToString< X >::Probe< XX, i >
 
class  is_Typelist< TY >
 Trait template for detecting a typelist type. More...
 
class  has_FunctionOperator< FUN >
 Trait template to detect presence of a simple function call operator. More...
 
struct  has_FunctionOperator< FUN >::Probe< FF, SEL >
 
struct  Marked< BAS, m >
 Metaprogramming helper to mark some arbitrary base type by subclassing. More...
 
struct  Tagged< BAS, TAG >
 
struct  StringConv< X, COND >
 failsafe invocation of custom string conversion. More...
 
struct  StringConv< X, lib::meta::enable_CustomStringConversion< X > >
 
struct  StringConv< X *, lib::meta::disable_if< std::__or_< std::is_same< std::remove_cv_t< X >, char >, std::is_same< std::remove_cv_t< X >, void > > > >
 specialisation to allow rendering pointers to string-convertible types. More...
 

Functions

string humanReadableTypeID (lib::Literal)
 pretty-print an internal C++ type representation
 
string primaryTypeComponent (lib::Literal)
 extract core name component from a raw type spec
 
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
 
string demangleCxx (Literal rawName)
 Fallback type-ID:
 
template<typename TY >
std::string typeStr (TY const *obj=nullptr) noexcept
 failsafe human readable type display
 
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
 
template<typename TY >
disable_if< std::is_pointer< TY >, std::string > typeSymbol (TY const &ref)
 
std::string showBool (bool yes) noexcept
 human readable display of boolean values
 
string showDouble (double) noexcept
 pretty-print a double in (rounded) fixed-point format
 
string showFloat (float val) noexcept
 
string showDecimal (double) noexcept
 show maximum reproducible decimal representation
 
string showDecimal (float val) noexcept
 
string showDecimal (f128 val) noexcept
 
string showComplete (double) noexcept
 show enough decimal digits to represent every distinct value
 
string showComplete (float val) noexcept
 
string showComplete (f128 val) noexcept
 
string showSize (size_t val) noexcept
 
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
 
template<typename X >
std::string showPtr (X *ptr=nullptr)
 diagnostics helper for explicitly indicating pointers
 
template<typename SP >
std::string showSmartPtr (SP const &smPtr, std::string label="smP")
 
uint operator""_KiB (ullong const siz)
 
uint operator""_MiB (ullong const siz)
 
ullong operator""_GiB (ullong const siz)
 

Class Documentation

◆ lib::meta::enable_if_c

struct lib::meta::enable_if_c
Class Members
typedef T type
+ Collaboration diagram for enable_if_c< B, T >:

◆ lib::meta::enable_if_c< false, T >

struct lib::meta::enable_if_c< false, T >
+ Collaboration diagram for enable_if_c< false, T >:

◆ lib::meta::No_t

struct lib::meta::No_t
Class Members
char more_than_one[4]
+ Collaboration diagram for No_t:

◆ lib::meta::anonymous_namespace{util.hpp}::_ExtractFirst

struct lib::meta::anonymous_namespace{util.hpp}::_ExtractFirst
Class Members
typedef void Type
+ Collaboration diagram for _ExtractFirst<... >:

◆ lib::meta::anonymous_namespace{util.hpp}::_ExtractFirst< X, XS... >

struct lib::meta::anonymous_namespace{util.hpp}::_ExtractFirst< X, XS... >
Class Members
typedef X Type
+ Collaboration diagram for _ExtractFirst< X, XS... >:

◆ lib::meta::can_convertToString::Probe

struct lib::meta::can_convertToString::Probe
+ Collaboration diagram for can_convertToString< X >::Probe< XX, i >:

◆ lib::meta::has_FunctionOperator::Probe

struct lib::meta::has_FunctionOperator::Probe
+ Collaboration diagram for has_FunctionOperator< FUN >::Probe< FF, SEL >:

Function Documentation

◆ operator""_KiB()

uint operator""_KiB ( ullong const  siz)
inline

Definition at line 509 of file meta/util.hpp.

◆ operator""_MiB()

uint operator""_MiB ( ullong const  siz)
inline

Definition at line 515 of file meta/util.hpp.

◆ operator""_GiB()

ullong operator""_GiB ( ullong const  siz)
inline

Definition at line 521 of file meta/util.hpp.