OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
StdCastAdapt< T, to_t > Struct Template Reference

#include <StdAdaptors.h>

Public Member Functions

 StdCastAdapt (T &rValue)
 
void CompileFunc (StdCompiler *pComp) const
 
template<class D >
bool operator== (const D &nValue) const
 
template<class D >
StdCastAdaptoperator= (const D &nValue)
 

Public Attributes

T & rValue
 

Detailed Description

template<class T, class to_t>
struct StdCastAdapt< T, to_t >

Definition at line 235 of file StdAdaptors.h.

Constructor & Destructor Documentation

template<class T , class to_t >
StdCastAdapt< T, to_t >::StdCastAdapt ( T &  rValue)
inlineexplicit

Definition at line 238 of file StdAdaptors.h.

238 : rValue(rValue) { }

Member Function Documentation

template<class T , class to_t >
void StdCastAdapt< T, to_t >::CompileFunc ( StdCompiler pComp) const
inline

Definition at line 239 of file StdAdaptors.h.

References StdCompiler::Value().

240  {
241  // Cast
242  static_assert(sizeof(to_t) == sizeof(T), "CastAdapt sanity: sizes match");
243  static_assert(std::is_pod<to_t>::value, "CastAdapt sanity: to-type is POD");
244  static_assert(std::is_pod<T>::value, "CastAdapt sanity: from-type is POD");
245  to_t vVal;
246  std::memcpy(&vVal, &rValue, sizeof(to_t));
247  pComp->Value(vVal);
248  std::memcpy(&rValue, &vVal, sizeof(T));
249  }
void Value(const T &rStruct)
Definition: StdCompiler.h:161

Here is the call graph for this function:

template<class T , class to_t >
template<class D >
StdCastAdapt& StdCastAdapt< T, to_t >::operator= ( const D &  nValue)
inline

Definition at line 252 of file StdAdaptors.h.

252 { rValue = nValue; return *this; }
template<class T , class to_t >
template<class D >
bool StdCastAdapt< T, to_t >::operator== ( const D &  nValue) const
inline

Definition at line 251 of file StdAdaptors.h.

251 { return rValue == nValue; }

Member Data Documentation

template<class T , class to_t >
T& StdCastAdapt< T, to_t >::rValue

Definition at line 237 of file StdAdaptors.h.


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