Jpp
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
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. More...
 
data_typeclone () const
 Get clone from temporary object. More...
 

Protected Member Functions

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

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

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

Definition at line 20 of file JObject.hh.

Constructor & Destructor Documentation

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

Default constructor.

Definition at line 51 of file JObject.hh.

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

Copy constructor.

Definition at line 58 of file JObject.hh.

59  {}

Member Function Documentation

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  return (data_type&) (*buffer);
34  }
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 42 of file JObject.hh.

43  {
44  return new T(static_cast<const T&>(*this));
45  }
template<class T>
JObject& JLANG::JObject< T >::operator= ( const JObject< T > &  )
private

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