type_trait.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /// @ref gtx_type_trait
  2. /// @file glm/gtx/type_trait.hpp
  3. ///
  4. /// @see core (dependence)
  5. ///
  6. /// @defgroup gtx_type_trait GLM_GTX_type_trait
  7. /// @ingroup gtx
  8. ///
  9. /// Include <glm/gtx/type_trait.hpp> to use the features of this extension.
  10. ///
  11. /// Defines traits for each type.
  12. #pragma once
  13. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  14. # ifndef GLM_ENABLE_EXPERIMENTAL
  15. # pragma message("GLM: GLM_GTX_type_trait is an experimental extension and may change in the future. Use #define GLM_ENABLE_EXPERIMENTAL before including it, if you really want to use it.")
  16. # else
  17. # pragma message("GLM: GLM_GTX_type_trait extension included")
  18. # endif
  19. #endif
  20. // Dependency:
  21. #include "../detail/qualifier.hpp"
  22. #include "../gtc/quaternion.hpp"
  23. #include "../gtx/dual_quaternion.hpp"
  24. namespace glm
  25. {
  26. /// @addtogroup gtx_type_trait
  27. /// @{
  28. template<typename T>
  29. struct type
  30. {
  31. static bool const is_vec = false;
  32. static bool const is_mat = false;
  33. static bool const is_quat = false;
  34. static length_t const components = 0;
  35. static length_t const cols = 0;
  36. static length_t const rows = 0;
  37. };
  38. template<length_t L, typename T, qualifier Q>
  39. struct type<vec<L, T, Q> >
  40. {
  41. static bool const is_vec = true;
  42. static bool const is_mat = false;
  43. static bool const is_quat = false;
  44. static length_t const components = L;
  45. };
  46. template<length_t C, length_t R, typename T, qualifier Q>
  47. struct type<mat<C, R, T, Q> >
  48. {
  49. static bool const is_vec = false;
  50. static bool const is_mat = true;
  51. static bool const is_quat = false;
  52. static length_t const components = C;
  53. static length_t const cols = C;
  54. static length_t const rows = R;
  55. };
  56. template<typename T, qualifier Q>
  57. struct type<qua<T, Q> >
  58. {
  59. static bool const is_vec = false;
  60. static bool const is_mat = false;
  61. static bool const is_quat = true;
  62. static length_t const components = 4;
  63. };
  64. template<typename T, qualifier Q>
  65. struct type<tdualquat<T, Q> >
  66. {
  67. static bool const is_vec = false;
  68. static bool const is_mat = false;
  69. static bool const is_quat = true;
  70. static length_t const components = 8;
  71. };
  72. /// @}
  73. }//namespace glm
  74. #include "type_trait.inl"