HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
hikogui
text
font_grapheme_id.hpp
1
// Copyright Take Vos 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 "../unicode/grapheme.hpp"
8
#include "../hash.hpp"
9
10
namespace
hi::inline
v1
{
11
14
struct
font_grapheme_id
{
15
hi::font
const
*
font
;
16
grapheme
g;
17
18
font_grapheme_id
(hi::font
const
&
font
,
grapheme
g) noexcept :
font
(&
font
), g(
std::move
(g)) {}
19
20
[[nodiscard]]
std::size_t
hash()
const
noexcept
21
{
22
hi_axiom(
font
);
23
return
hash_mix(
reinterpret_cast<
ptrdiff_t
>
(
font
), g);
24
}
25
26
[[nodiscard]]
friend
bool
operator==(
font_grapheme_id
const
&lhs,
font_grapheme_id
const
&rhs)
noexcept
27
{
28
hi_axiom(lhs.font and rhs.font);
29
return
(lhs.font == rhs.font) and (lhs.g == rhs.g);
30
}
31
};
32
33
}
// namespace hi::inline v1
34
35
template
<>
36
struct
std::hash
<
hi
::font_grapheme_id> {
37
[[nodiscard]]
std::size_t
operator()
(hi::font_grapheme_id
const
&rhs)
const
noexcept
38
{
39
return
rhs.hash();
40
}
41
};
v1
DOXYGEN BUG.
Definition
algorithm.hpp:15
hi
The HikoGUI namespace.
Definition
ascii.hpp:19
v1::font
Definition
font.hpp:32
v1::font_grapheme_id
Combined font_id + grapheme for use as a key in a std::unordered_map.
Definition
font_grapheme_id.hpp:14
v1::grapheme
A grapheme-cluster, what a user thinks a character is.
Definition
grapheme.hpp:41
std::hash
std::move
T move(T... args)
std::hash::operator()
T operator()(T... args)
std::size_t
Generated on Mon Apr 22 2024 12:53:20 for HikoGUI by
1.10.0