1/*
2 SPDX-FileCopyrightText: 2021 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#ifndef MAPENTRY_P_H
8#define MAPENTRY_P_H
9
10#include <algorithm>
11#include <cstdint>
12#include <iterator>
13
14#pragma pack(push)
15#pragma pack(1)
16
17template<typename KeyType>
18struct MapEntry {
19 KeyType key;
20 uint16_t value;
21};
22
23template<typename KeyType>
24constexpr inline bool operator<(MapEntry<KeyType> lhs, MapEntry<KeyType> rhs)
25{
26 return lhs.key < rhs.key;
27}
28
29template<typename KeyType>
30constexpr inline bool operator<(MapEntry<KeyType> lhs, KeyType rhs)
31{
32 return lhs.key < rhs;
33}
34
35template<typename KeyType>
36constexpr inline bool operator<(KeyType lhs, MapEntry<KeyType> rhs)
37{
38 return lhs < rhs.key;
39}
40
41template<typename MapEntry, std::size_t N>
42inline constexpr bool isSortedLookupTable(const MapEntry (&map)[N])
43{
44#if __cplusplus > 201703L && defined(__GNUC__) && __GNUC__ > 9 && !defined(__clang__)
45 return std::is_sorted(std::begin(map), std::end(map));
46#else
47 (void)map;
48 return true;
49#endif
50}
51
52#pragma pack(pop)
53
54#endif
55

source code of ki18n/src/localedata/mapentry_p.h