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 261 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 264 of file StdAdaptors.h.

264 : 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 265 of file StdAdaptors.h.

266  {
267  // Cast
268  static_assert(sizeof(to_t) == sizeof(T), "CastAdapt sanity: sizes match");
269  static_assert(std::is_pod<to_t>::value, "CastAdapt sanity: to-type is POD");
270  static_assert(std::is_pod<T>::value, "CastAdapt sanity: from-type is POD");
271  to_t vVal;
272  std::memcpy(&vVal, &rValue, sizeof(to_t));
273  pComp->Value(vVal);
274  std::memcpy(&rValue, &vVal, sizeof(T));
275  }
void Value(const T &rStruct)
Definition: StdCompiler.h:161

References StdCastAdapt< T, to_t >::rValue, and StdCompiler::Value().

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

278 { rValue = nValue; return *this; }

References StdCastAdapt< T, to_t >::rValue.

◆ operator==()

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

Definition at line 277 of file StdAdaptors.h.

277 { return rValue == nValue; }

References StdCastAdapt< T, to_t >::rValue.

Member Data Documentation

◆ rValue

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

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