hash.h 671 B

12345678910111213141516171819202122232425262728
  1. // SPDX-FileCopyrightText: 2015 Citra Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <cstddef>
  5. #include <utility>
  6. #include <boost/functional/hash.hpp>
  7. namespace Common {
  8. struct PairHash {
  9. template <class T1, class T2>
  10. std::size_t operator()(const std::pair<T1, T2>& pair) const noexcept {
  11. std::size_t seed = std::hash<T1>()(pair.first);
  12. boost::hash_combine(seed, std::hash<T2>()(pair.second));
  13. return seed;
  14. }
  15. };
  16. template <typename T>
  17. struct IdentityHash {
  18. [[nodiscard]] size_t operator()(T value) const noexcept {
  19. return static_cast<size_t>(value);
  20. }
  21. };
  22. } // namespace Common