OSSIA
Open Scenario System for Interactive Application
Loading...
Searching...
No Matches
value_hash.hpp
1#pragma once
2#include <ossia/detail/hash.hpp>
3#include <ossia/network/value/value.hpp>
4
5#include <functional>
6
7namespace std
8{
9template <>
10struct hash<ossia::impulse>
11{
12
13 std::size_t operator()(const ossia::impulse& v) const
14 {
15 if constexpr(sizeof(std::size_t) == 8)
16 return 4412470058203171781ul;
17 else
18 return 3958788809ul;
19 }
20};
21template <>
22struct hash<std::vector<ossia::value>>
23{
24 inline std::size_t operator()(const std::vector<ossia::value>& v) const;
25};
26
27template <std::size_t N>
28struct hash<std::array<float, N>>
29{
30 std::size_t operator()(const std::array<float, N>& v) const
31 {
32 std::size_t seed = 0;
33 for(std::size_t i = 0; i < N; i++)
34 ossia::hash_combine(seed, v[i]);
35 return seed;
36 }
37};
38
39template <>
40struct hash<ossia::value>
41{
42 std::size_t operator()(const ossia::value& v) const
43 {
44 std::size_t seed = 0;
45 ossia::hash_combine(seed, v.v.which());
46 if(v.valid())
47 ossia::apply_nonnull(
48 [&](const auto& val) { ossia::hash_combine(seed, val); }, v.v);
49 return seed;
50 }
51};
52
53inline std::size_t std::hash<std::vector<ossia::value>>::operator()(
54 const std::vector<ossia::value>& v) const
55{
56 std::size_t seed = 0;
57 for(const auto& val : v)
58 ossia::hash_combine(seed, hash<ossia::value>{}(val));
59 return seed;
60}
61
62}
The value class.
Definition value.hpp:173
Definition git_info.h:7