Advertisement
Blue_Kirby

getvfunc

May 2nd, 2014
411
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #pragma once
  2.  
  3. inline void**& getvtable( void* inst, size_t offset = 0 )
  4. {
  5.     return *reinterpret_cast<void***>( (size_t)inst + offset );
  6. }
  7. inline const void** getvtable( const void* inst, size_t offset = 0 )
  8. {
  9.     return *reinterpret_cast<const void***>( (size_t)inst + offset );
  10. }
  11. template< typename Fn >
  12. inline Fn getvfunc( const void* inst, size_t index, size_t offset = 0 )
  13. {
  14.     return reinterpret_cast<Fn>( getvtable( inst, offset )[ index ] );
  15. }
  16. //===================================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement