summaryrefslogtreecommitdiff
path: root/src/common/hash.h
blob: 15ef80289dc289848098b42b43cb3e2f8246f3b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-FileCopyrightText: 2015 Citra Emulator Project & 2025 Citron Homebrew Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <cstddef>
#include <utility>
#include <boost/functional/hash.hpp>

namespace Common {

struct PairHash {
    template <class T1, class T2>
    std::size_t operator()(const std::pair<T1, T2>& pair) const noexcept {
        std::size_t seed = std::hash<T1>()(pair.first);
        boost::hash_combine(seed, std::hash<T2>()(pair.second));
        return seed;
    }
};

template <typename T>
struct IdentityHash {
    [[nodiscard]] size_t operator()(T value) const noexcept {
        return static_cast<size_t>(value);
    }
};

} // namespace Common