functional.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * Copyright (c) 2012-2023 Daniele Bartolini et al.
  3. * SPDX-License-Identifier: MIT
  4. */
  5. #pragma once
  6. #include "core/types.h"
  7. namespace crown
  8. {
  9. template<typename T>
  10. struct equal_to
  11. {
  12. bool operator()(const T &a, const T &b) const;
  13. };
  14. template<typename T>
  15. struct not_equal_to
  16. {
  17. bool operator()(const T &a, const T &b) const;
  18. };
  19. template<typename T>
  20. struct greater
  21. {
  22. bool operator()(const T &a, const T &b) const;
  23. };
  24. template<typename T>
  25. struct less
  26. {
  27. bool operator()(const T &a, const T &b) const;
  28. };
  29. template<typename T>
  30. struct greater_equal
  31. {
  32. bool operator()(const T &a, const T &b) const;
  33. };
  34. template<typename T>
  35. struct less_equal
  36. {
  37. bool operator()(const T &a, const T &b) const;
  38. };
  39. template<typename T>
  40. struct hash;
  41. template<>
  42. struct hash<bool>
  43. {
  44. u32 operator()(const bool val) const;
  45. };
  46. template<>
  47. struct hash<s8>
  48. {
  49. u32 operator()(const s8 val) const;
  50. };
  51. template<>
  52. struct hash<u8>
  53. {
  54. u32 operator()(const u8 val) const;
  55. };
  56. template<>
  57. struct hash<s16>
  58. {
  59. u32 operator()(const s16 val) const;
  60. };
  61. template<>
  62. struct hash<u16>
  63. {
  64. u32 operator()(const u16 val) const;
  65. };
  66. template<>
  67. struct hash<s32>
  68. {
  69. u32 operator()(const s32 val) const;
  70. };
  71. template<>
  72. struct hash<u32>
  73. {
  74. u32 operator()(const u32 val) const;
  75. };
  76. template<>
  77. struct hash<s64>
  78. {
  79. u32 operator()(const s64 val) const;
  80. };
  81. template<>
  82. struct hash<u64>
  83. {
  84. u32 operator()(const u64 val) const;
  85. };
  86. template<>
  87. struct hash<f32>
  88. {
  89. u32 operator()(const f32 val) const;
  90. };
  91. template<>
  92. struct hash<f64>
  93. {
  94. u32 operator()(const f64 val) const;
  95. };
  96. template<typename T>
  97. struct hash<T *>
  98. {
  99. u32 operator()(const T *val) const;
  100. };
  101. } // namespace crown