Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
trait.hpp File Reference

Helpers for type detection, type rewriting and metaprogramming. More...

Go to the source code of this file.

Description

Helpers for type detection, type rewriting and metaprogramming.

This header is a collection of frequently used templates for working with types. It incurs only modest header inclusion overhead

Warning
be sure not to jeopardise that!
unwrapping
Strip away all kinds of type adornments, like const, reference, pointer, smart-ptr. The accompanying lib::meta::unwrap() function can be used to accept "stuff packaged in various forms". The Strip template packages this ability in various degrees for metaprogramming
Warning
these helpers can be quite dangerous, as they silently break any protective barriers (including lifecycle managing smart-ptrs)
string conversion
a set of trait templates to categorise arbitrary types with respect to the ability for string conversions
ability to iterate
these traits can be used to build the notion of a generic container – basically anything that can be enumerated. Within Lumiera, we frequently use our own concept of "iterability", known as "Lumiera Forward Iterator". These helpers here allow to unify this concept with the "Range" concept from the standard library (begin() and end())
See also
MetaUtils_test
format-obj.hpp string representation for anything
meta/util.hpp very basic metaprogramming helpers
typelist.hpp

Definition in file trait.hpp.

#include "lib/meta/util.hpp"
#include "lib/meta/duck-detector.hpp"
#include <type_traits>

Namespaces

namespace  boost
 
namespace  std
 STL namespace.
 
namespace  lib
 Implementation namespace for support and library code.
 
namespace  lib::hash
 Hash implementations usable for the HashIndexed mixin as well as key within std::unordered_map.
 
namespace  lib::time
 
namespace  steam
 Steam-Layer implementation namespace root.
 
namespace  steam::mobject
 Media-Objects, edit operations and high-level session.
 
namespace  lib::meta
 

Macros

#define TRAIT_IS_NARROWING(_SRC_, _TAR_)
 

Classes

struct  Unwrap< X >
 Helper for type analysis and convenience accessors: attempts to extract a base type from various wrappers. More...
 
struct  Unwrap< void >
 < More...
 
struct  Unwrap< X * >
 
struct  Unwrap< boost::reference_wrapper< X > >
 
struct  Unwrap< std::reference_wrapper< X > >
 
struct  Unwrap< std::unique_ptr< X, D > >
 
struct  Unwrap< std::shared_ptr< X > >
 
struct  Unwrap< P< X, B > >
 
struct  Strip< X >
 Helper for type analysis: tries to strip all kinds of type adornments. More...
 
struct  RefTraits< TY >
 Type definition helper for pointer and reference types. More...
 
struct  RefTraits< TY * >
 
struct  RefTraits< TY & >
 
struct  RefTraits< TY && >
 
struct  is_basicallySame< T, U >
 compare unadorned types, disregarding const and references More...
 
struct  is_Subclass< S, I >
 verify compliance to an interface by subtype check More...
 
struct  is_basically< S, I >
 compare for unadorned base type, disregarding const and references More...
 
struct  can_StandIn< S, G >
 verify the first (special) type can stand-in for the second More...
 
struct  is_StringLike< X >
 detect various flavours of string / text data More...
 
struct  can_lexical2string< X >
 types able to be lexically converted to string representation More...
 
struct  use_LexicalConversion< X >
 
struct  is_StreamSource< X >
 
struct  use_StringConversion4Stream< X >
 when to use custom string conversions for output streams More...
 
struct  is_smart_ptr< X >
 detect smart pointers More...
 
struct  is_smart_ptr< std::shared_ptr< T > >
 
struct  is_smart_ptr< std::unique_ptr< T, D > >
 
struct  is_nonFloat< NUM >
 
struct  is_narrowingInit< SRC, TAR >
 temporary workaround for GCC Bug-63723, necessary until CGG-5 More...
 
struct  is_narrowingInit< lib::hash::LuidH, TAR >
 
class  can_IterForEach< T >
 Trait template to detect a type usable immediately as "Lumiera Forward Iterator" in a specialised for-each loop This is just a heuristic, based on some common properties of such iterators; it is enough to distinguish it from an STL container, but can certainly be refined. More...
 
class  is_StateCore< T >
 Trait template to detect a type exposing a »state core« API. More...
 
class  can_STL_ForEach< T >
 Trait template to detect a type usable with the STL for-each loop. More...
 
struct  can_STL_ForEach< T >::is_iterable
 
struct  can_STL_ForEach< T >::is_noexcept_iterable
 
struct  can_STL_ForEach< T >::is_const_iterable
 
struct  can_STL_ForEach< T >::is_const_noexcept_iterable
 
class  can_STL_backIteration< T >
 Trait template to detect a type also supporting STL-style backwards iteration. More...
 
struct  can_STL_backIteration< T >::is_backIterable
 
struct  can_STL_backIteration< T >::is_noexcept_backIterable
 
struct  can_STL_backIteration< T >::is_const_backIterable
 
struct  can_STL_backIteration< T >::is_const_noexcept_backIterable
 

Functions

template<typename X >
Unwrap< X >::Typeunwrap (X const &wrapped)
 convenience shortcut: unwrapping free function.
 

Variables

template<typename T >
static constexpr bool isConst_v = std::is_const_v<remove_reference_t<T>>
 
template<typename T >
static constexpr bool isLRef_v = std::is_lvalue_reference_v<T>
 
template<typename T >
static constexpr bool isRRef_v = std::is_rvalue_reference_v<T>
 
template<typename T >
static constexpr bool isRef_v = std::is_reference_v<T>
 

Macro Definition Documentation

◆ TRAIT_IS_NARROWING

#define TRAIT_IS_NARROWING (   _SRC_,
  _TAR_ 
)
Value:
template<> \
struct is_narrowingInit<_SRC_, _TAR_> \
: std::true_type \
{ };

Definition at line 464 of file trait.hpp.


Class Documentation

◆ lib::meta::Strip

struct lib::meta::Strip
Class Members
typedef conditional_t< is_reference_v< X >, conditional_t< is_rvalue_reference_v< X >, remove_cv_t< remove_reference_t< X > > &&, remove_cv_t< remove_reference_t< X > > & >, remove_cv_t< X > > TypeUnconst
typedef remove_reference_t< TypeUnconst > TypeReferred
typedef remove_pointer_t< TypeReferred > TypePointee
typedef remove_cv_t< TypePointee > TypePlain
typedef Type Type
+ Inheritance diagram for Strip< X >:
+ Collaboration diagram for Strip< X >:

◆ lib::meta::RefTraits

struct lib::meta::RefTraits
Class Members
typedef TY Value
typedef TY * Pointer
typedef TY & Reference
+ Collaboration diagram for RefTraits< TY >:

◆ lib::meta::RefTraits< TY * >

struct lib::meta::RefTraits< TY * >
Class Members
typedef TY * Value
typedef TY ** Pointer
typedef TY *& Reference
+ Collaboration diagram for RefTraits< TY * >:

◆ lib::meta::RefTraits< TY & >

struct lib::meta::RefTraits< TY & >
Class Members
typedef TY Value
typedef TY * Pointer
typedef TY & Reference
+ Collaboration diagram for RefTraits< TY & >:

◆ lib::meta::RefTraits< TY && >

struct lib::meta::RefTraits< TY && >
Class Members
typedef TY Value
typedef TY * Pointer
typedef TY & Reference
+ Collaboration diagram for RefTraits< TY && >: