method_index.h 489 B

123456789101112131415161718192021222324
  1. #pragma once
  2. #include <util/system/platform.h>
  3. #include <cstring>
  4. #include <cstdint>
  5. namespace NYql {
  6. size_t GetMethodPtrIndex(uintptr_t ptr);
  7. template<typename Method>
  8. inline size_t GetMethodIndex(Method method) {
  9. uintptr_t ptr;
  10. std::memcpy(&ptr, &method, sizeof(uintptr_t));
  11. return GetMethodPtrIndex(ptr);
  12. }
  13. template<typename Method>
  14. inline uintptr_t GetMethodPtr(Method method) {
  15. uintptr_t ptr;
  16. std::memcpy(&ptr, &method, sizeof(uintptr_t));
  17. return ptr;
  18. }
  19. }