23inline std::size_t
combine(std::size_t seed, std::size_t
h)
noexcept
25 seed ^=
h + 0x9e3779b9 + (seed << 6U) + (seed >> 2U);
40template<
typename BasicJsonType>
41std::size_t
hash(
const BasicJsonType& j)
43 using string_t =
typename BasicJsonType::string_t;
44 using number_integer_t =
typename BasicJsonType::number_integer_t;
45 using number_unsigned_t =
typename BasicJsonType::number_unsigned_t;
46 using number_float_t =
typename BasicJsonType::number_float_t;
48 const auto type =
static_cast<std::size_t
>(j.type());
51 case BasicJsonType::value_t::null:
52 case BasicJsonType::value_t::discarded:
57 case BasicJsonType::value_t::object:
60 for (
const auto& element : j.items())
62 const auto h = std::hash<string_t> {}(element.key());
72 for (
const auto& element : j)
79 case BasicJsonType::value_t::string:
81 const auto h = std::hash<string_t> {}(j.template get_ref<const string_t&>());
85 case BasicJsonType::value_t::boolean:
87 const auto h = std::hash<bool> {}(j.template get<bool>());
91 case BasicJsonType::value_t::number_integer:
93 const auto h = std::hash<number_integer_t> {}(j.template get<number_integer_t>());
97 case BasicJsonType::value_t::number_unsigned:
99 const auto h = std::hash<number_unsigned_t> {}(j.template get<number_unsigned_t>());
103 case BasicJsonType::value_t::number_float:
105 const auto h = std::hash<number_float_t> {}(j.template get<number_float_t>());
109 case BasicJsonType::value_t::binary:
112 const auto h = std::hash<bool> {}(j.get_binary().has_subtype());
114 seed =
combine(seed,
static_cast<std::size_t
>(j.get_binary().subtype()));
115 for (
const auto byte : j.get_binary())
117 seed =
combine(seed, std::hash<std::uint8_t> {}(byte));
#define WPI_JSON_NAMESPACE_END
Definition: abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition: abi_macros.h:53
#define JSON_ASSERT(x)
Definition: macro_scope.h:192
detail namespace with internal helper functions
Definition: xchar.h:20
std::size_t hash(const BasicJsonType &j)
hash a JSON value
Definition: hash.h:41
std::size_t combine(std::size_t seed, std::size_t h) noexcept
Definition: hash.h:23
type
Definition: core.h:556
static constexpr const unit_t< compound_unit< energy::joule, time::seconds > > h(6.626070040e-34)
Planck constant.
array(T, Ts...) -> array< T, 1+sizeof...(Ts)>