Audacity  2.2.2
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Maybe< X > Class Template Reference

#include <MemoryX.h>

Public Member Functions

 Maybe ()
 
 Maybe (const Maybe &that)
 
Maybeoperator= (const Maybe &that)
 
 Maybe (Maybe &&that)
 
Maybeoperator= (Maybe &&that)
 
template<typename... Args>
void create (Args &&...args)
 
 ~Maybe ()
 
X & operator* () const
 
X * operator-> () const
 
X * get () const
 
void reset ()
 
 operator bool () const
 

Private Member Functions

X * address ()
 

Private Attributes

union {
   double   d
 
   char   storage [sizeof(X)]
 
}; 
 
X * pp { nullptr }
 

Detailed Description

template<typename X>
class Maybe< X >

Definition at line 204 of file MemoryX.h.

Constructor & Destructor Documentation

template<typename X>
Maybe< X >::Maybe ( )
inline

Definition at line 208 of file MemoryX.h.

208 {}
template<typename X>
Maybe< X >::Maybe ( const Maybe< X > &  that)
inline

Definition at line 211 of file MemoryX.h.

212  {
213  if (that.get())
214  create(*that);
215  }
X * get() const
Definition: MemoryX.h:278
void create(Args &&...args)
Definition: MemoryX.h:251
template<typename X>
Maybe< X >::Maybe ( Maybe< X > &&  that)
inline

Definition at line 228 of file MemoryX.h.

229  {
230  if (that.get())
231  create(::std::move(*that));
232  }
X * get() const
Definition: MemoryX.h:278
void create(Args &&...args)
Definition: MemoryX.h:251
template<typename X>
Maybe< X >::~Maybe ( )
inline

Definition at line 260 of file MemoryX.h.

261  {
262  reset();
263  }
void reset()
Definition: MemoryX.h:283

Member Function Documentation

template<typename X>
X* Maybe< X >::address ( )
inlineprivate

Definition at line 296 of file MemoryX.h.

Referenced by Maybe< ProgressDialog >::create().

297  {
298  return reinterpret_cast<X*>(&storage);
299  }
char storage[sizeof(X)]
Definition: MemoryX.h:310
template<typename X>
template<typename... Args>
void Maybe< X >::create ( Args &&...  args)
inline
template<typename X>
X* Maybe< X >::get ( ) const
inline

Definition at line 278 of file MemoryX.h.

Referenced by Maybe< ProgressDialog >::Maybe(), and Maybe< ProgressDialog >::operator=().

279  {
280  return pp;
281  }
X * pp
Definition: MemoryX.h:313
template<typename X>
Maybe< X >::operator bool ( ) const
inlineexplicit

Definition at line 290 of file MemoryX.h.

291  {
292  return pp != nullptr;
293  }
X * pp
Definition: MemoryX.h:313
template<typename X>
X& Maybe< X >::operator* ( ) const
inline

Definition at line 268 of file MemoryX.h.

269  {
270  return *pp;
271  }
X * pp
Definition: MemoryX.h:313
template<typename X>
X* Maybe< X >::operator-> ( ) const
inline

Definition at line 273 of file MemoryX.h.

274  {
275  return pp;
276  }
X * pp
Definition: MemoryX.h:313
template<typename X>
Maybe& Maybe< X >::operator= ( const Maybe< X > &  that)
inline

Definition at line 217 of file MemoryX.h.

218  {
219  if (this != &that) {
220  if (that.get())
221  create(*that);
222  else
223  reset();
224  }
225  return *this;
226  }
void reset()
Definition: MemoryX.h:283
X * get() const
Definition: MemoryX.h:278
void create(Args &&...args)
Definition: MemoryX.h:251
template<typename X>
Maybe& Maybe< X >::operator= ( Maybe< X > &&  that)
inline

Definition at line 234 of file MemoryX.h.

235  {
236  if (this != &that) {
237  if (that.get())
238  create(::std::move(*that));
239  else
240  reset();
241  }
242  return *this;
243  }
void reset()
Definition: MemoryX.h:283
X * get() const
Definition: MemoryX.h:278
void create(Args &&...args)
Definition: MemoryX.h:251
template<typename X>
void Maybe< X >::reset ( )
inline

Definition at line 283 of file MemoryX.h.

Referenced by Maybe< ProgressDialog >::create(), Maybe< ProgressDialog >::operator=(), and Maybe< ProgressDialog >::~Maybe().

284  {
285  if (pp)
286  pp->~X(), pp = nullptr;
287  }
X * pp
Definition: MemoryX.h:313

Member Data Documentation

union { ... }
template<typename X>
double Maybe< X >::d

Definition at line 309 of file MemoryX.h.

template<typename X>
X* Maybe< X >::pp { nullptr }
private
template<typename X>
char Maybe< X >::storage[sizeof(X)]

Definition at line 310 of file MemoryX.h.

Referenced by Maybe< ProgressDialog >::address().


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