Advertisement
eliasdaler

Stupid type id which I use currently (no RTTI)

Sep 18th, 2016
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.37 KB | None | 0 0
  1. // MIT license
  2. // Stupid type id which I use
  3.  
  4. #pragma once
  5.  
  6. #include <cstdint>
  7.  
  8. namespace Meta {
  9.  
  10. using TypeId = uintptr_t;
  11.  
  12. template <typename T>
  13. TypeId getTypeId()
  14. {    // We use adress of this static dummy boolean as a unique id for classes!
  15.     static bool dummy = false;
  16.     static const auto id = reinterpret_cast<TypeId>(&dummy);
  17.     return id;
  18. }
  19.  
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement