hash_combine.hpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright 2005-2014 Daniel James.
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Based on Peter Dimov's proposal
  8. // http://www.open-std.org/JTC1/SC22/WG21/docs/papers/2005/n1756.pdf
  9. // issue 6.18.
  10. //
  11. // This also contains public domain code from MurmurHash. From the
  12. // MurmurHash header:
  13. //
  14. // MurmurHash3 was written by Austin Appleby, and is placed in the public
  15. // domain. The author hereby disclaims copyright to this source code.
  16. //
  17. // Copyright 2021 Ion Gaztanaga
  18. // Refactored the original Boost ContainerHash library to avoid
  19. // any heavy std header dependencies to just combine two hash
  20. // values represented in a std::size_t type.
  21. //
  22. // See http://www.boost.org/libs/intrusive for documentation.
  23. //
  24. /////////////////////////////////////////////////////////////////////////////
  25. #ifndef BOOST_INTRUSIVE_DETAIL_HASH_COMBINE_HPP
  26. #define BOOST_INTRUSIVE_DETAIL_HASH_COMBINE_HPP
  27. #ifndef BOOST_CONFIG_HPP
  28. # include <boost/config.hpp>
  29. #endif
  30. #if defined(BOOST_HAS_PRAGMA_ONCE)
  31. # pragma once
  32. #endif
  33. #include <boost/cstdint.hpp>
  34. #include "hash_mix.hpp"
  35. namespace boost {
  36. namespace intrusive {
  37. namespace detail {
  38. inline void hash_combine_size_t(std::size_t& seed, std::size_t value)
  39. {
  40. seed = boost::intrusive::detail::hash_mix(seed + 0x9e3779b9 + value);
  41. }
  42. } //namespace detail {
  43. } //namespace intrusive {
  44. } //namespace boost {
  45. #endif //BOOST_INTRUSIVE_DETAIL_HASH_COMBINE_HPP