Lumiera  0.pre.03
»edit your freedom«
ScopedHolder< TY > Class Template Reference

#include "lib/scoped-holder.hpp"

Description

template<class TY>
class lib::ScopedHolder< TY >

Inline buffer holding and owning an object similar to unique_ptr.

Access to the contained object is similar to a smart-pointer, but the object isn't heap allocated, rather placed into an buffer within ScopedHolder. Initially, ScopedHolder is empty and behaves like a null pointer. The contained object must be created explicitly by calling #create() (using the default ctor). This state change is remembered (requiring 1 char of additional storage). After the creation of the object, ScopedHolder is effectively noncopyable, which is enforced by run-time checks. ScopedHolder may be used to hold noncopyable objects within STL containers inline without extra heap allocation.

Definition at line 144 of file scoped-holder.hpp.

Public Member Functions

 ScopedHolder (ScopedHolder const &ref)
 
void clear ()
 
TY & create ()
 
TY & create (TY const &o)
 
TY * get () const
 
 operator bool () const
 
bool operator! () const
 
TY & operator* () const
 
TY * operator-> () const
 
ScopedHolderoperator= (ScopedHolder const &ref)
 

Friends

void transfer_control (ScopedHolder &from, ScopedHolder &to)
 

Static Private Member Functions

static char must_be_empty (ScopedHolder< TY > const &ref)
 

Private Attributes

char content_ [sizeof(TY)]
 
char created_
 

Member Function Documentation

◆ create()

TY& create ( TY const &  o)
inline
Parameters
oplace new content object using copy ctor

Definition at line 177 of file scoped-holder.hpp.

+ Inheritance diagram for ScopedHolder< TY >:
+ Collaboration diagram for ScopedHolder< TY >:

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