hash.hpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. /// @ref gtx_hash
  2. /// @file glm/gtx/hash.hpp
  3. ///
  4. /// @see core (dependence)
  5. ///
  6. /// @defgroup gtx_hash GLM_GTX_hash
  7. /// @ingroup gtx
  8. ///
  9. /// Include <glm/gtx/hash.hpp> to use the features of this extension.
  10. ///
  11. /// Add std::hash support for glm types
  12. #pragma once
  13. #if GLM_MESSAGES == GLM_ENABLE && !defined(GLM_EXT_INCLUDED)
  14. # ifndef GLM_ENABLE_EXPERIMENTAL
  15. # pragma message("GLM: GLM_GTX_hash 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_hash extension included")
  18. # endif
  19. #endif
  20. #include <functional>
  21. #include "../vec2.hpp"
  22. #include "../vec3.hpp"
  23. #include "../vec4.hpp"
  24. #include "../gtc/vec1.hpp"
  25. #include "../gtc/quaternion.hpp"
  26. #include "../gtx/dual_quaternion.hpp"
  27. #include "../mat2x2.hpp"
  28. #include "../mat2x3.hpp"
  29. #include "../mat2x4.hpp"
  30. #include "../mat3x2.hpp"
  31. #include "../mat3x3.hpp"
  32. #include "../mat3x4.hpp"
  33. #include "../mat4x2.hpp"
  34. #include "../mat4x3.hpp"
  35. #include "../mat4x4.hpp"
  36. #if !GLM_HAS_CXX11_STL
  37. # error "GLM_GTX_hash requires C++11 standard library support"
  38. #endif
  39. namespace std
  40. {
  41. template<typename T, glm::qualifier Q>
  42. struct hash<glm::vec<1, T,Q> >
  43. {
  44. GLM_FUNC_DECL size_t operator()(glm::vec<1, T, Q> const& v) const;
  45. };
  46. template<typename T, glm::qualifier Q>
  47. struct hash<glm::vec<2, T,Q> >
  48. {
  49. GLM_FUNC_DECL size_t operator()(glm::vec<2, T, Q> const& v) const;
  50. };
  51. template<typename T, glm::qualifier Q>
  52. struct hash<glm::vec<3, T,Q> >
  53. {
  54. GLM_FUNC_DECL size_t operator()(glm::vec<3, T, Q> const& v) const;
  55. };
  56. template<typename T, glm::qualifier Q>
  57. struct hash<glm::vec<4, T,Q> >
  58. {
  59. GLM_FUNC_DECL size_t operator()(glm::vec<4, T, Q> const& v) const;
  60. };
  61. template<typename T, glm::qualifier Q>
  62. struct hash<glm::qua<T,Q>>
  63. {
  64. GLM_FUNC_DECL size_t operator()(glm::qua<T, Q> const& q) const;
  65. };
  66. template<typename T, glm::qualifier Q>
  67. struct hash<glm::tdualquat<T,Q> >
  68. {
  69. GLM_FUNC_DECL size_t operator()(glm::tdualquat<T,Q> const& q) const;
  70. };
  71. template<typename T, glm::qualifier Q>
  72. struct hash<glm::mat<2, 2, T,Q> >
  73. {
  74. GLM_FUNC_DECL size_t operator()(glm::mat<2, 2, T,Q> const& m) const;
  75. };
  76. template<typename T, glm::qualifier Q>
  77. struct hash<glm::mat<2, 3, T,Q> >
  78. {
  79. GLM_FUNC_DECL size_t operator()(glm::mat<2, 3, T,Q> const& m) const;
  80. };
  81. template<typename T, glm::qualifier Q>
  82. struct hash<glm::mat<2, 4, T,Q> >
  83. {
  84. GLM_FUNC_DECL size_t operator()(glm::mat<2, 4, T,Q> const& m) const;
  85. };
  86. template<typename T, glm::qualifier Q>
  87. struct hash<glm::mat<3, 2, T,Q> >
  88. {
  89. GLM_FUNC_DECL size_t operator()(glm::mat<3, 2, T,Q> const& m) const;
  90. };
  91. template<typename T, glm::qualifier Q>
  92. struct hash<glm::mat<3, 3, T,Q> >
  93. {
  94. GLM_FUNC_DECL size_t operator()(glm::mat<3, 3, T,Q> const& m) const;
  95. };
  96. template<typename T, glm::qualifier Q>
  97. struct hash<glm::mat<3, 4, T,Q> >
  98. {
  99. GLM_FUNC_DECL size_t operator()(glm::mat<3, 4, T,Q> const& m) const;
  100. };
  101. template<typename T, glm::qualifier Q>
  102. struct hash<glm::mat<4, 2, T,Q> >
  103. {
  104. GLM_FUNC_DECL size_t operator()(glm::mat<4, 2, T,Q> const& m) const;
  105. };
  106. template<typename T, glm::qualifier Q>
  107. struct hash<glm::mat<4, 3, T,Q> >
  108. {
  109. GLM_FUNC_DECL size_t operator()(glm::mat<4, 3, T,Q> const& m) const;
  110. };
  111. template<typename T, glm::qualifier Q>
  112. struct hash<glm::mat<4, 4, T,Q> >
  113. {
  114. GLM_FUNC_DECL size_t operator()(glm::mat<4, 4, T,Q> const& m) const;
  115. };
  116. } // namespace std
  117. #include "hash.inl"