HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
src
ttauri
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 "grapheme.hpp"
8
#include "../hash.hpp"
9
10
namespace
tt {
11
14
struct
font_grapheme_id
{
15
tt::font
const
*
font
;
16
grapheme
g;
17
18
font_grapheme_id
(
tt::font
const
&
font
,
grapheme
g) noexcept :
font
(&
font
), g(
std::move
(g)) {}
19
20
[[nodiscard]]
size_t
hash()
const
noexcept
21
{
22
tt_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
tt_axiom(lhs.font and rhs.font);
29
return
(lhs.font == rhs.font) and (lhs.g == rhs.g);
30
}
31
};
32
33
}
// namespace tt
34
35
namespace
std
{
36
37
template
<>
38
struct
hash
<tt::font_grapheme_id> {
39
[[nodiscard]]
size_t
operator()
(
tt::font_grapheme_id
const
&rhs)
const
noexcept
40
{
41
return
rhs.hash();
42
}
43
};
44
45
}
// namespace std
std
STL namespace.
tt::font
Definition
font.hpp:28
tt::font_grapheme_id
Combined font_id + grapheme for use as a key in a std::unordered_map.
Definition
font_grapheme_id.hpp:14
tt::grapheme
Definition
grapheme.hpp:21
std::hash
std::move
T move(T... args)
std::hash::operator()
T operator()(T... args)
Generated on Mon Apr 22 2024 12:53:31 for HikoGUI by
1.10.0