GetPrimitiveTypeOfType.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #include <Jolt/Core/RTTI.h>
  5. JPH_NAMESPACE_BEGIN
  6. /// Helper functions to get the underlying RTTI type of a type (so e.g. Array<sometype> will return sometype)
  7. template <class T>
  8. const RTTI *GetPrimitiveTypeOfType(T *)
  9. {
  10. return GetRTTIOfType((T *)nullptr);
  11. }
  12. template <class T>
  13. const RTTI *GetPrimitiveTypeOfType(T **)
  14. {
  15. return GetRTTIOfType((T *)nullptr);
  16. }
  17. template <class T>
  18. const RTTI *GetPrimitiveTypeOfType(Ref<T> *)
  19. {
  20. return GetRTTIOfType((T *)nullptr);
  21. }
  22. template <class T>
  23. const RTTI *GetPrimitiveTypeOfType(RefConst<T> *)
  24. {
  25. return GetRTTIOfType((T *)nullptr);
  26. }
  27. template <class T>
  28. const RTTI *GetPrimitiveTypeOfType(Array<T> *)
  29. {
  30. return GetPrimitiveTypeOfType((T *)nullptr);
  31. }
  32. template <class T, uint N>
  33. const RTTI *GetPrimitiveTypeOfType(StaticArray<T, N> *)
  34. {
  35. return GetPrimitiveTypeOfType((T *)nullptr);
  36. }
  37. template <class T, uint N>
  38. const RTTI *GetPrimitiveTypeOfType(T (*)[N])
  39. {
  40. return GetPrimitiveTypeOfType((T *)nullptr);
  41. }
  42. JPH_NAMESPACE_END