OpenClonk
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 253 of file StdAdaptors.h.

Constructor & Destructor Documentation

◆ StdCastAdapt()

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

Definition at line 256 of file StdAdaptors.h.

256 : rValue(rValue) { }

Member Function Documentation

◆ CompileFunc()

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

Definition at line 257 of file StdAdaptors.h.

References StdCompiler::Value().

258  {
259  // Cast
260  static_assert(sizeof(to_t) == sizeof(T), "CastAdapt sanity: sizes match");
261  static_assert(std::is_pod<to_t>::value, "CastAdapt sanity: to-type is POD");
262  static_assert(std::is_pod<T>::value, "CastAdapt sanity: from-type is POD");
263  to_t vVal;
264  std::memcpy(&vVal, &rValue, sizeof(to_t));
265  pComp->Value(vVal);
266  std::memcpy(&rValue, &vVal, sizeof(T));
267  }
void Value(const T &rStruct)
Definition: StdCompiler.h:161
Here is the call graph for this function:

◆ operator=()

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

Definition at line 270 of file StdAdaptors.h.

270 { rValue = nValue; return *this; }

◆ operator==()

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

Definition at line 269 of file StdAdaptors.h.

269 { return rValue == nValue; }

Member Data Documentation

◆ rValue

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

Definition at line 255 of file StdAdaptors.h.


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