Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qcontainerinfo.h
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QCONTAINERINFO_H
6#define QCONTAINERINFO_H
7
8#include <QtCore/qglobal.h>
9#include <type_traits>
10
11QT_BEGIN_NAMESPACE
12
13namespace QContainerInfo {
14
15template<typename C>
16using value_type = typename C::value_type;
17
18template<typename C>
19using key_type = typename C::key_type;
20
21template<typename C>
22using mapped_type = typename C::mapped_type;
23
24template<typename C>
25using iterator = typename C::iterator;
26
27template<typename C>
28using const_iterator = typename C::const_iterator;
29
30// Some versions of Apple clang warn about the constexpr variables below being unused.
31QT_WARNING_PUSH
32QT_WARNING_DISABLE_CLANG("-Wunused-const-variable")
33
34template<typename C, typename = void>
35inline constexpr bool has_value_type_v = false;
36template<typename C>
37inline constexpr bool has_value_type_v<C, std::void_t<value_type<C>>> = true;
38
39template<typename C, typename = void>
40inline constexpr bool has_key_type_v = false;
41template<typename C>
42inline constexpr bool has_key_type_v<C, std::void_t<key_type<C>>> = true;
43
44template<typename C, typename = void>
45inline constexpr bool has_mapped_type_v = false;
46template<typename C>
47inline constexpr bool has_mapped_type_v<C, std::void_t<mapped_type<C>>> = true;
48
49template<typename C, typename = void>
50inline constexpr bool has_size_v = false;
51template<typename C>
52inline constexpr bool has_size_v<C, std::void_t<decltype(C().size())>> = true;
53
54template<typename C, typename = void>
55inline constexpr bool has_reserve_v = false;
56template<typename C>
57inline constexpr bool has_reserve_v<C, std::void_t<decltype(C().reserve(0))>> = true;
58
59template<typename C, typename = void>
60inline constexpr bool has_clear_v = false;
61template<typename C>
62inline constexpr bool has_clear_v<C, std::void_t<decltype(C().clear())>> = true;
63
64template<typename, typename = void>
65inline constexpr bool has_at_index_v = false;
66template<typename C>
67inline constexpr bool has_at_index_v<C, std::void_t<decltype(C().at(0))>> = true;
68
69template<typename, typename = void>
70inline constexpr bool has_at_key_v = false;
71template<typename C>
72inline constexpr bool has_at_key_v<C, std::void_t<decltype(C().at(key_type<C>()))>> = true;
73
74template<typename, typename = void>
75inline constexpr bool can_get_at_index_v = false;
76template<typename C>
77inline constexpr bool can_get_at_index_v<C, std::void_t<value_type<C>(decltype(C()[0]))>> = true;
78
79template<typename, typename = void>
80inline constexpr bool can_set_at_index_v = false;
81template<typename C>
82inline constexpr bool can_set_at_index_v<C, std::void_t<decltype(C()[0] = value_type<C>())>> = true;
83
84template<typename, typename = void>
85inline constexpr bool has_push_front_v = false;
86template<typename C>
87inline constexpr bool has_push_front_v<C, std::void_t<decltype(C().push_front(value_type<C>()))>> = true;
88
89template<typename, typename = void>
90inline constexpr bool has_push_back_v = false;
91template<typename C>
92inline constexpr bool has_push_back_v<C, std::void_t<decltype(C().push_back(value_type<C>()))>> = true;
93
94template<typename, typename = void>
95inline constexpr bool has_insert_v = false;
96template<typename C>
97inline constexpr bool has_insert_v<C, std::void_t<decltype(C().insert(value_type<C>()))>> = true;
98
99template<typename, typename = void>
100inline constexpr bool has_pop_front_v = false;
101template<typename C>
102inline constexpr bool has_pop_front_v<C, std::void_t<decltype(C().pop_front())>> = true;
103
104template<typename, typename = void>
105inline constexpr bool has_pop_back_v = false;
106template<typename C>
107inline constexpr bool has_pop_back_v<C, std::void_t<decltype(C().pop_back())>> = true;
108
109template<typename, typename = void>
110inline constexpr bool has_iterator_v = false;
111template<typename C>
112inline constexpr bool has_iterator_v<C, std::void_t<iterator<C>>> = true;
113
114template<typename, typename = void>
115inline constexpr bool has_const_iterator_v = false;
116template<typename C>
117inline constexpr bool has_const_iterator_v<C, std::void_t<const_iterator<C>>> = true;
118
119template<typename, typename = void>
120inline constexpr bool can_set_value_at_iterator_v = false;
121template<typename C>
122inline constexpr bool can_set_value_at_iterator_v<C, std::void_t<decltype(*C().begin() = value_type<C>())>> = true;
123
124template<typename, typename = void>
125inline constexpr bool can_set_mapped_at_iterator_v = false;
126template<typename C>
127inline constexpr bool can_set_mapped_at_iterator_v<C, std::void_t<decltype(*C().begin() = mapped_type<C>())>> = true;
128
129template<typename, typename = void>
130inline constexpr bool can_insert_value_at_iterator_v = false;
131template<typename C>
132inline constexpr bool can_insert_value_at_iterator_v<C, std::void_t<decltype(C().insert(C().begin(), value_type<C>()))>> = true;
133
134template<typename, typename = void>
135inline constexpr bool can_erase_at_iterator_v = false;
136template<typename C>
137inline constexpr bool can_erase_at_iterator_v<C, std::void_t<decltype(C().erase(C().begin()))>> = true;
138
139template<typename, typename = void>
140inline constexpr bool can_erase_range_at_iterator_v = false;
141template<typename C>
142inline constexpr bool can_erase_range_at_iterator_v<C, std::void_t<decltype(C().erase(C().begin(), C().end()))>> = true;
143
144template<typename, typename = void>
145inline constexpr bool can_get_at_key_v = false;
146template<typename C>
147inline constexpr bool can_get_at_key_v<C, std::void_t<mapped_type<C>(decltype(C()[key_type<C>()]))>> = true;
148
149template<typename, typename = void>
150inline constexpr bool can_set_at_key_v = false;
151template<typename C>
152inline constexpr bool can_set_at_key_v<C, std::void_t<decltype(C()[key_type<C>()] = mapped_type<C>())>> = true;
153
154template<typename, typename = void>
155inline constexpr bool can_erase_at_key_v = false;
156template<typename C>
157inline constexpr bool can_erase_at_key_v<C, std::void_t<decltype(C().erase(key_type<C>()))>> = true;
158
159template<typename, typename = void>
160inline constexpr bool can_remove_at_key_v = false;
161template<typename C>
162inline constexpr bool can_remove_at_key_v<C, std::void_t<decltype(C().remove(key_type<C>()))>> = true;
163
164template<typename, typename = void>
165inline constexpr bool can_insert_key_v = false;
166template<typename C>
167inline constexpr bool can_insert_key_v<C, std::void_t<decltype(C().insert(key_type<C>()))>> = true;
168
169template<typename, typename = void>
170inline constexpr bool can_insert_pair_v = false;
171template<typename C>
172inline constexpr bool can_insert_pair_v<C, std::void_t<decltype(C().insert({key_type<C>(), mapped_type<C>()}))>> = true;
173
174template<typename, typename = void>
175inline constexpr bool can_insert_key_mapped_v = false;
176template<typename C>
177inline constexpr bool can_insert_key_mapped_v<C, std::void_t<decltype(C().insert(key_type<C>(), mapped_type<C>()))>> = true;
178
179template<typename, typename = void>
180inline constexpr bool has_contains_v = false;
181template<typename C>
182inline constexpr bool has_contains_v<C, std::void_t<decltype(bool(C().contains(key_type<C>())))>> = true;
183
184template<typename, typename = void>
185inline constexpr bool has_find_v = false;
186template<typename C>
187inline constexpr bool has_find_v<C, std::void_t<decltype(C().find(key_type<C>()))>> = true;
188
189template<typename, typename = void>
190inline constexpr bool iterator_dereferences_to_value_v = false;
191template<typename C>
192inline constexpr bool iterator_dereferences_to_value_v<C, std::void_t<decltype(value_type<C>(*C().begin()))>> = true;
193
194template<typename, typename = void>
195inline constexpr bool iterator_has_key_v = false;
196template<typename C>
197inline constexpr bool iterator_has_key_v<C, std::void_t<decltype(key_type<C>(C().begin().key()))>> = true;
198
199template<typename, typename = void>
200inline constexpr bool value_type_has_first_v = false;
201template<typename C>
202inline constexpr bool value_type_has_first_v<C, std::void_t<decltype(key_type<C>(value_type<C>().first))>> = true;
203
204template<typename, typename = void>
205inline constexpr bool iterator_dereferences_to_key_v = false;
206template<typename C>
207inline constexpr bool iterator_dereferences_to_key_v<C, std::void_t<decltype(key_type<C>(*C().begin()))>> = true;
208
209template<typename, typename = void>
210inline constexpr bool iterator_has_value_v = false;
211template<typename C>
212inline constexpr bool iterator_has_value_v<C, std::void_t<decltype(mapped_type<C>(C().begin().value()))>> = true;
213
214template<typename, typename = void>
215inline constexpr bool value_type_has_second_v = false;
216template<typename C>
217inline constexpr bool value_type_has_second_v<C, std::void_t<decltype(mapped_type<C>(value_type<C>().second))>> = true;
218
219template<typename, typename = void>
220inline constexpr bool iterator_dereferences_to_mapped_v = false;
221template<typename C>
222inline constexpr bool iterator_dereferences_to_mapped_v<C, std::void_t<decltype(mapped_type<C>(*C().begin()))>> = true;
223
225
226}
227
228QT_END_NAMESPACE
229
230#endif // QCONTAINERINFO_H
constexpr bool has_push_back_v
constexpr bool has_push_front_v
constexpr bool can_erase_at_key_v
constexpr bool can_set_value_at_iterator_v
constexpr bool has_iterator_v
constexpr bool has_insert_v
constexpr bool can_erase_at_iterator_v
constexpr bool has_reserve_v
constexpr bool can_set_at_index_v
constexpr bool iterator_has_value_v
constexpr bool has_pop_back_v
constexpr bool has_mapped_type_v
constexpr bool has_contains_v
constexpr bool iterator_has_key_v
constexpr bool can_insert_key_mapped_v
constexpr bool can_get_at_key_v
constexpr bool iterator_dereferences_to_value_v
constexpr bool can_remove_at_key_v
typename C::mapped_type mapped_type
constexpr bool iterator_dereferences_to_mapped_v
constexpr bool can_set_mapped_at_iterator_v
constexpr bool can_insert_pair_v
typename C::key_type key_type
constexpr bool value_type_has_first_v
constexpr bool can_erase_range_at_iterator_v
constexpr bool value_type_has_second_v
constexpr bool has_key_type_v
constexpr bool iterator_dereferences_to_key_v
constexpr bool has_clear_v
constexpr bool has_at_key_v
typename C::value_type value_type
constexpr bool can_insert_key_v
constexpr bool has_pop_front_v
typename C::iterator iterator
constexpr bool has_at_index_v
constexpr bool can_set_at_key_v
constexpr bool can_get_at_index_v
typename C::const_iterator const_iterator
constexpr bool has_find_v
constexpr bool can_insert_value_at_iterator_v
constexpr bool has_size_v
constexpr bool has_const_iterator_v