Lumiera  0.pre.03
»edit your freedom«
trait.hpp File Reference

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 iter-adapter.hppLumiera 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>

Classes

class  basic_filebuf< C, T >
 
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...
 
struct  can_lexical2string< X >
 types able to be lexically converted to string representation More...
 
struct  can_StandIn< S, G >
 verify the first (special) type can stand-in for the second More...
 
class  can_STL_backIteration< T >
 Trait template to detect a type also supporting STL-style backwards iteration. More...
 
class  can_STL_ForEach< T >
 Trait template to detect a type usable with the STL for-each loop. More...
 
class  char_traits< C >
 
struct  can_STL_backIteration< T >::is_backIterable
 
struct  is_basically< S, I >
 compare for unadorned base type, disregarding const and references More...
 
struct  is_basicallySame< T, U >
 compare unadorned types, disregarding const and references More...
 
struct  can_STL_backIteration< T >::is_const_backIterable
 
struct  can_STL_ForEach< T >::is_const_iterable
 
struct  can_STL_backIteration< T >::is_const_noexcept_backIterable
 
struct  can_STL_ForEach< T >::is_const_noexcept_iterable
 
struct  can_STL_ForEach< T >::is_iterable
 
struct  is_narrowingInit< SRC, TAR >
 temporary workaround for GCC [Bug-63723], necessary until CGG-5 More...
 
struct  is_narrowingInit< lib::hash::LuidH, TAR >
 
struct  can_STL_backIteration< T >::is_noexcept_backIterable
 
struct  can_STL_ForEach< T >::is_noexcept_iterable
 
struct  is_nonFloat< NUM >
 
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 > >
 
class  is_StateCore< T >
 Trait template to detect a type exposing a »state core« API. More...
 
struct  is_StreamSource< X >
 
struct  is_StringLike< X >
 detect various flavours of string / text data More...
 
struct  is_Subclass< S, I >
 verify compliance to an interface by subtype check More...
 
class  P< TAR, BASE >
 Customised refcounting smart pointer template, built upon std::shared_ptr, but forwarding type relationships and ordering operators to the pointee objects. More...
 
class  Placement< MO, B >
 A refcounting Handle to an MObject of type MO, used to constrain or explicitly specify the location where the MObject is supposed to be within the Session/Model. More...
 
class  reference_wrapper< X >
 
class  reference_wrapper< X >
 
struct  RefTraits< TY >
 Type definition helper for pointer and reference types. More...
 
struct  RefTraits< TY & >
 
struct  RefTraits< TY && >
 
struct  RefTraits< TY * >
 
class  shared_ptr< X >
 
struct  Strip< X >
 Helper for type analysis: tries to strip all kinds of type adornments. More...
 
class  unique_ptr< T >
 STL class.
 
struct  Unwrap< X >
 Helper for type analysis and convenience accessors: attempts to extract a base type from various wrappers. More...
 
struct  Unwrap< boost::reference_wrapper< X > >
 
struct  Unwrap< P< X, B > >
 
struct  Unwrap< std::reference_wrapper< X > >
 
struct  Unwrap< std::shared_ptr< X > >
 
struct  Unwrap< std::unique_ptr< X, D > >
 
struct  Unwrap< void >
 < More...
 
struct  Unwrap< X * >
 
struct  use_LexicalConversion< X >
 
struct  use_StringConversion4Stream< X >
 when to use custom string conversions for output streams More...
 

Macros

#define TRAIT_IS_NARROWING(_SRC_, _TAR_)
 

Functions

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

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 isRef_v = std::is_reference_v<T>
 
template<typename T >
static constexpr bool isRRef_v = std::is_rvalue_reference_v<T>
 

Namespaces

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

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.

Function Documentation

◆ unwrap()

Unwrap<X>::Type& lib::meta::unwrap ( X const &  wrapped)

convenience shortcut: unwrapping free function.

Returns
reference to the bare element.
Warning
this function is dangerous: it strips away any managing smart-ptr and any const! You might even access and return a reference to an anonymous temporary.

Definition at line 240 of file trait.hpp.

References lib::meta::unwrap().

Referenced by lib::meta::unwrap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: