source: opengl-game/utils.h@ bae0911

feature/imgui-sdl points-test
Last change on this file since bae0911 was 7e10667, checked in by Dmitry Portnoy <dmitry.portnoy@…>, 6 years ago

Finish switching to the new model group rendering algorithm for TYPE_EXPLOSION objects

  • Property mode set to 100644
File size: 561 bytes
Line 
1// Code for offset_of talem from https://gist.github.com/graphitemaster/494f21190bb2c63c5516
2
3template <typename T1, typename T2>
4struct offset_of_impl {
5 static T2 object;
6 static constexpr size_t offset(T1 T2::*member) {
7 return size_t(&(offset_of_impl<T1, T2>::object.*member)) -
8 size_t(&offset_of_impl<T1, T2>::object);
9 }
10};
11template <typename T1, typename T2>
12T2 offset_of_impl<T1, T2>::object;
13
14template <typename T1, typename T2>
15inline constexpr size_t offset_of(T1 T2::*member) {
16 return offset_of_impl<T1, T2>::offset(member);
17}
Note: See TracBrowser for help on using the repository browser.