Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
hash_combine.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef FLUTTER_FML_HASH_COMBINE_H_
6#define FLUTTER_FML_HASH_COMBINE_H_
7
8#include <functional>
9
10namespace fml {
11
12template <class Type>
13constexpr void HashCombineSeed(std::size_t& seed, Type arg) {
14 seed ^= std::hash<Type>{}(arg) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
15}
16
17template <class Type, class... Rest>
18constexpr void HashCombineSeed(std::size_t& seed,
19 Type arg,
20 Rest... other_args) {
21 HashCombineSeed(seed, arg);
22 HashCombineSeed(seed, other_args...);
23}
24
25[[nodiscard]] constexpr std::size_t HashCombine() {
26 return 0xdabbad00;
27}
28
29template <class... Type>
30[[nodiscard]] constexpr std::size_t HashCombine(Type... args) {
31 std::size_t seed = HashCombine();
32 HashCombineSeed(seed, args...);
33 return seed;
34}
35
36} // namespace fml
37
38#endif // FLUTTER_FML_HASH_COMBINE_H_
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
constexpr std::size_t HashCombine()
constexpr void HashCombineSeed(std::size_t &seed, Type arg)