]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/json/detail/digest.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / json / detail / digest.hpp
CommitLineData
20effc67
TL
1//
2// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3//
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// Official repository: https://github.com/boostorg/json
8//
9
10#ifndef BOOST_JSON_DETAIL_DIGEST_HPP
11#define BOOST_JSON_DETAIL_DIGEST_HPP
12
13BOOST_JSON_NS_BEGIN
14namespace detail {
15
16// Calculate salted digest of string
1e59de90 17template<class ForwardIterator>
20effc67
TL
18std::size_t
19digest(
1e59de90
TL
20 ForwardIterator b,
21 ForwardIterator e,
20effc67
TL
22 std::size_t salt) noexcept
23{
24#if BOOST_JSON_ARCH == 64
25 std::uint64_t const prime = 0x100000001B3ULL;
26 std::uint64_t hash = 0xcbf29ce484222325ULL;
27#else
28 std::uint32_t const prime = 0x01000193UL;
29 std::uint32_t hash = 0x811C9DC5UL;
30#endif
31 hash += salt;
1e59de90
TL
32 for(; b != e; ++b)
33 hash = (*b ^ hash) * prime;
20effc67
TL
34 return hash;
35}
36
37} // detail
38BOOST_JSON_NS_END
39
40#endif