#ifndef B8D59B54_1674_4C0F_AA2C_611385FF5D03 #define B8D59B54_1674_4C0F_AA2C_611385FF5D03 #include "gh_base.h" #include "gh_static_mem.h" #include "gh_types.h" #include "gh_global.h" #ifdef _WIN32 #include #include #else #include #endif template struct Field {}; template struct _FieldBinderSizeTraits { using type = undefined; }; template <> struct _FieldBinderSizeTraits<4> { using type = undefined4; }; template <> struct _FieldBinderSizeTraits<2> { using type = undefined2; }; template <> struct _FieldBinderSizeTraits<3> { using type = undefined3; }; template struct FieldBinder { void *dst; using ExpectedType = typename _FieldBinderSizeTraits::type; operator ExpectedType &() const { return *reinterpret_cast(dst); } template T *operator=(T *src) { union V { T *a; void* b; }; V* trick = reinterpret_cast(this); return trick->a = src; } ExpectedType& operator=(ExpectedType src) { return *reinterpret_cast(dst) = src; } }; template inline FieldBinder operator+(const void *str, Field offset) { return FieldBinder{.dst = (uint8_t *)str + Offset}; } #endif /* B8D59B54_1674_4C0F_AA2C_611385FF5D03 */