// Copyright (C) 2015 Jérôme Leclercq // This file is part of the "Nazara Engine - Core module" // For conditions of distribution and use, see copyright notice in Config.hpp #pragma once #ifndef NAZARA_OFFSETOF_HPP #define NAZARA_OFFSETOF_HPP // Par "Jesse Good" de SO: // http://stackoverflow.com/questions/12811330/c-compile-time-offsetof-inside-a-template?answertab=votes#tab-top template T NzImplGetClassType(M T::*); template M NzImplGetMemberType(M T::*); template constexpr std::size_t NzImplOffsetOf() { return reinterpret_cast(&((static_cast(0))->*M)); } #define NzOffsetOf(type, member) NzImplOffsetOf() #endif // NAZARA_OFFSETOF_HPP