Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
ItemWrapper< TY > Class Template Reference

#include "lib/item-wrapper.hpp"

Description

template<typename TY>
class lib::wrapper::ItemWrapper< TY >

Universal value/ref wrapper accessible similar to a pointer.

A copyable, assignable value object to hold a given value within an embedded inline buffer. It can be default constructed and bool evaluated to detect an empty holder. The value is retrieved through a pointer-like interface, by explicit dereferentiation. (Contrast this to std::ref, where the original reference is retrieved by conversion).

Note
when the embedded value is a pointer, ItemWrapper does not take ownership of and manage data the pointer is pointing to.

The purpose of this template is to be able to remember pretty much any kind of value or pointer or reference, and to subsume this handling within a single template. An example would be to remember the value yielded by a function, without any further assumptions regarding this function.

Definition at line 78 of file item-wrapper.hpp.

Public Member Functions

 ItemWrapper ()
 
 ItemWrapper (TY const &o)
 
 ItemWrapper (TY &&ro)
 
 ~ItemWrapper ()
 
 ItemWrapper (ItemWrapper const &ref)
 
 ItemWrapper (ItemWrapper &&rref)
 
ItemWrapperoperator= (ItemWrapper const &cref)
 
ItemWrapperoperator= (ItemWrapper &ref)
 
ItemWrapperoperator= (ItemWrapper &&rref)
 
template<typename X >
ItemWrapperoperator= (X &&something)
 Emulate »assignment« by discarding and then construction of a new payload.
 
ItemWrapperdefaultInit ()
 implant a default-initialised instance of the payload type
 
 operator bool () const
 
TY & operator* () const
 
TY * operator-> () const
 
bool isValid () const
 
void reset ()
 

Private Types

using TY_unconst = std::remove_const_t< TY >
 

Private Member Functions

template<typename REF >
void build (REF &&ref)
 
void discard ()
 
TY & access () const
 
TY_unconstaccess_unconst () const
 < used to assign new buffer contents
 

Private Attributes

std::byte content_ [sizeof(TY)]
 
bool created_
 

Constructor & Destructor Documentation

◆ ItemWrapper() [1/5]

template<typename TY >
ItemWrapper ( )
inline

Definition at line 117 of file item-wrapper.hpp.

◆ ItemWrapper() [2/5]

template<typename TY >
ItemWrapper ( TY const &  o)
inlineexplicit

Definition at line 122 of file item-wrapper.hpp.

References ItemWrapper< TY >::build().

+ Here is the call graph for this function:

◆ ItemWrapper() [3/5]

template<typename TY >
ItemWrapper ( TY &&  ro)
inlineexplicit

Definition at line 128 of file item-wrapper.hpp.

References ItemWrapper< TY >::build().

+ Here is the call graph for this function:

◆ ~ItemWrapper()

template<typename TY >
~ItemWrapper ( )
inline

Definition at line 134 of file item-wrapper.hpp.

References ItemWrapper< TY >::discard().

+ Here is the call graph for this function:

◆ ItemWrapper() [4/5]

template<typename TY >
ItemWrapper ( ItemWrapper< TY > const &  ref)
inline

Definition at line 142 of file item-wrapper.hpp.

References ItemWrapper< TY >::build(), and ItemWrapper< TY >::isValid().

+ Here is the call graph for this function:

◆ ItemWrapper() [5/5]

template<typename TY >
ItemWrapper ( ItemWrapper< TY > &&  rref)
inline

Definition at line 148 of file item-wrapper.hpp.

References ItemWrapper< TY >::build().

+ Here is the call graph for this function:

Member Typedef Documentation

◆ TY_unconst

template<typename TY >
using TY_unconst = std::remove_const_t<TY>
private

Definition at line 81 of file item-wrapper.hpp.

Member Function Documentation

◆ build()

template<typename TY >
template<typename REF >
void build ( REF &&  ref)
inlineprivate

Definition at line 91 of file item-wrapper.hpp.

References ItemWrapper< TY >::content_, and ItemWrapper< TY >::created_.

Referenced by ItemWrapper< TY >::ItemWrapper(), ItemWrapper< TY >::ItemWrapper(), ItemWrapper< TY >::ItemWrapper(), ItemWrapper< TY >::ItemWrapper(), ItemWrapper< TY >::defaultInit(), and ItemWrapper< TY >::operator=().

+ Here is the caller graph for this function:

◆ discard()

template<typename TY >
void discard ( )
inlineprivate

Definition at line 98 of file item-wrapper.hpp.

References ItemWrapper< TY >::access(), and ItemWrapper< TY >::created_.

Referenced by ItemWrapper< TY >::~ItemWrapper(), ItemWrapper< TY >::defaultInit(), ItemWrapper< TY >::operator=(), ItemWrapper< TY >::operator=(), ItemWrapper< TY >::operator=(), and ItemWrapper< TY >::reset().

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

◆ access()

template<typename TY >
TY & access ( ) const
inlineprivate

Definition at line 105 of file item-wrapper.hpp.

References ItemWrapper< TY >::content_.

Referenced by ItemWrapper< TY >::access_unconst(), ItemWrapper< TY >::discard(), ItemWrapper< TY >::operator*(), and ItemWrapper< TY >::operator=().

+ Here is the caller graph for this function:

◆ access_unconst()

template<typename TY >
TY_unconst & access_unconst ( ) const
inlineprivate

< used to assign new buffer contents

Definition at line 111 of file item-wrapper.hpp.

References ItemWrapper< TY >::access().

+ Here is the call graph for this function:

◆ operator=() [1/4]

template<typename TY >
ItemWrapper & operator= ( ItemWrapper< TY > const &  cref)
inline

Definition at line 159 of file item-wrapper.hpp.

References ItemWrapper< TY >::discard(), ItemWrapper< TY >::isValid(), and ItemWrapper< TY >::operator=().

Referenced by ItemWrapper< TY >::operator=(), and ItemWrapper< TY >::operator=().

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

◆ operator=() [2/4]

template<typename TY >
ItemWrapper & operator= ( ItemWrapper< TY > &  ref)
inline

Definition at line 169 of file item-wrapper.hpp.

◆ operator=() [3/4]

template<typename TY >
ItemWrapper & operator= ( ItemWrapper< TY > &&  rref)
inline

Definition at line 174 of file item-wrapper.hpp.

References ItemWrapper< TY >::discard(), and ItemWrapper< TY >::operator=().

+ Here is the call graph for this function:

◆ operator=() [4/4]

template<typename TY >
template<typename X >
ItemWrapper & operator= ( X &&  something)
inline

Emulate »assignment« by discarding and then construction of a new payload.

Parameters
somethingfrom which TY can be (copy/move)constructed
Remarks
allows handling »move-only« types; for the typical use case, something new is fabricated in a lambda and then moved into the ItemWrapper; thus the performance overhead of destroy/re-created is not deemed relevant. SFINAE tricks on hidden/deleted assignment operator can be unreliable.

Definition at line 197 of file item-wrapper.hpp.

References ItemWrapper< TY >::access(), ItemWrapper< TY >::build(), and ItemWrapper< TY >::discard().

+ Here is the call graph for this function:

◆ defaultInit()

template<typename TY >
ItemWrapper & defaultInit ( )
inline

implant a default-initialised instance of the payload type

Definition at line 209 of file item-wrapper.hpp.

References ItemWrapper< TY >::build(), and ItemWrapper< TY >::discard().

Referenced by ActivityDetector::DiagnosticFun< RET, ARGS >::DiagnosticFun().

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

◆ operator bool()

template<typename TY >
operator bool ( ) const
inline

Definition at line 216 of file item-wrapper.hpp.

References ItemWrapper< TY >::isValid().

+ Here is the call graph for this function:

◆ operator*()

template<typename TY >
TY & operator* ( ) const
inline

Definition at line 224 of file item-wrapper.hpp.

References ItemWrapper< TY >::access(), ItemWrapper< TY >::created_, and LERR_.

+ Here is the call graph for this function:

◆ operator->()

template<typename TY >
TY * operator-> ( ) const
inline

Definition at line 233 of file item-wrapper.hpp.

◆ isValid()

template<typename TY >
bool isValid ( ) const
inline

Definition at line 239 of file item-wrapper.hpp.

References ItemWrapper< TY >::created_.

Referenced by ItemWrapper< TY >::ItemWrapper(), SingleValCore< VAL >::evaluate(), FunctionResult< SIG >::isValid(), ItemWrapper< TY >::operator bool(), and ItemWrapper< TY >::operator=().

+ Here is the caller graph for this function:

◆ reset()

template<typename TY >
void reset ( )
inline

Definition at line 245 of file item-wrapper.hpp.

References ItemWrapper< TY >::discard().

Referenced by SingleValCore< VAL >::advance(), MementoTie< SIG, MEM >::clear(), Transformer< SRC, RES >::expandChildren(), Transformer< SRC, RES >::iterNext(), TransformingCore< IT, VAL >::processItem(), and ItemWrapper_test::verifyWrapper().

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

Member Data Documentation

◆ content_

template<typename TY >
std::byte content_[sizeof(TY)]
mutableprivate

Definition at line 85 of file item-wrapper.hpp.

Referenced by ItemWrapper< TY >::access(), and ItemWrapper< TY >::build().

◆ created_

template<typename TY >
bool created_
private
+ Inheritance diagram for ItemWrapper< TY >:
+ Collaboration diagram for ItemWrapper< TY >:

The documentation for this class was generated from the following file: