HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
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
10namespace tt {
11
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
35namespace std {
36
37template<>
38struct 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
STL namespace.
Definition font.hpp:28
Combined font_id + grapheme for use as a key in a std::unordered_map.
Definition font_grapheme_id.hpp:14
Definition grapheme.hpp:21
T move(T... args)
T operator()(T... args)