HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
hash.hpp
1// Copyright Take Vos 2020-2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "utility.hpp"
8#include "assert.hpp"
9#include <utility>
10#include <array>
11#include <type_traits>
12
13namespace hi::inline v1 {
14
15[[nodiscard]] constexpr std::size_t hash_mix_two(std::size_t hash1, std::size_t hash2) noexcept
16{
17 if constexpr (sizeof(std::size_t) == 8) {
18 return hash1 + 0x9e3779b97f681800 + (hash2 << 6) + (hash2 >> 2);
19 } else if constexpr (sizeof(std::size_t) == 4) {
20 return hash1 + 0x9e3779b9 + (hash2 << 6) + (hash2 >> 2);
21 } else {
23 }
24}
25
26template<typename First, typename Second, typename... Args>
27[[nodiscard]] constexpr std::size_t hash_mix(First &&first, Second &&second, Args &&...args) noexcept
28{
29 if constexpr (sizeof...(args) == 0) {
30 return hash_mix_two(
31 std::hash<std::remove_cvref_t<First>>{}(std::forward<First>(first)),
32 std::hash<std::remove_cvref_t<Second>>{}(std::forward<Second>(second)));
33 } else {
34 return hash_mix_two(
35 std::hash<std::remove_cvref_t<First>>{}(std::forward<First>(first)),
36 hash_mix(std::forward<Second>(second), std::forward<Args>(args)...));
37 }
38}
39
40} // namespace hi::inline v1
Utilities to assert and bound check.
#define hi_not_implemented()
This part of the code has not been implemented yet.
Definition assert.hpp:182
Utilities used by the HikoGUI library itself.
DOXYGEN BUG.
Definition algorithm.hpp:15