Jpp test-rotations-old
the software that should make you happy
Loading...
Searching...
No Matches
JLANG::JObject< T > Struct Template Reference

Auxiliary base class for inline creation of a static value or clone from a temporary object. More...

#include <JObject.hh>

Public Types

typedef T data_type
 

Public Member Functions

data_typegetInstance ()
 Get static instance from temporary object.
 
data_typeclone () const
 Get clone from temporary object.
 

Protected Member Functions

 JObject ()
 Default constructor.
 
 JObject (const JObject &)
 Copy constructor.
 

Private Member Functions

JObjectoperator= (const JObject &)
 

Detailed Description

template<class T>
struct JLANG::JObject< T >

Auxiliary base class for inline creation of a static value or clone from a temporary object.

Definition at line 18 of file JObject.hh.

Member Typedef Documentation

◆ data_type

template<class T >
T JLANG::JObject< T >::data_type

Definition at line 20 of file JObject.hh.

Constructor & Destructor Documentation

◆ JObject() [1/2]

template<class T >
JLANG::JObject< T >::JObject ( )
inlineprotected

Default constructor.

Definition at line 53 of file JObject.hh.

54 {}

◆ JObject() [2/2]

template<class T >
JLANG::JObject< T >::JObject ( const JObject< T > & )
inlineprotected

Copy constructor.

Definition at line 60 of file JObject.hh.

61 {}

Member Function Documentation

◆ getInstance()

template<class T >
data_type & JLANG::JObject< T >::getInstance ( )
inline

Get static instance from temporary object.

Returns
reference to static object

Definition at line 27 of file JObject.hh.

28 {
29 static char buffer[sizeof(T)];
30
31 new (buffer) T(static_cast<const T&>(*this));
32
33 T* p = reinterpret_cast<data_type*>(buffer);
34
35 return *p;
36 }

◆ clone()

template<class T >
data_type * JLANG::JObject< T >::clone ( ) const
inline

Get clone from temporary object.

Returns
pointer to newly created object

Definition at line 44 of file JObject.hh.

45 {
46 return new T(static_cast<const T&>(*this));
47 }

◆ operator=()

template<class T >
JObject & JLANG::JObject< T >::operator= ( const JObject< T > & )
private

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