MySQL 9.6.0
Source Code Documentation
aliases.h
Go to the documentation of this file.
1// Copyright (c) 2024, 2025, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
23
24#ifndef MYSQL_SETS_ALIASES_H
25#define MYSQL_SETS_ALIASES_H
26
27/// @file
28/// Experimental API header
29
30#include "mysql/meta/not_decayed.h" // Not_decayed
31#include "mysql/sets/interval_container.h" // Interval_container
32#include "mysql/sets/map_nested_storage.h" // Map_nested_storage
33#include "mysql/sets/nested_container.h" // Nested_container
34#include "mysql/sets/nested_set_traits.h" // Nested_set_traits
35#include "mysql/sets/nonthrowing_boundary_container_adaptor.h" // Nonthrowing_boundary_container_adaptor
37#include "mysql/sets/set_traits.h" // Is_bounded_set_traits
38#include "mysql/sets/throwing/boundary_container.h" // Boundary_container
39#include "mysql/sets/throwing/map_boundary_storage.h" // Map_boundary_storage
40#include "mysql/sets/throwing/vector_boundary_storage.h" // Vector_boundary_storage
41
42/// @addtogroup GroupLibsMysqlSets
43/// @{
44
45// ==== Helpers ====
46
47namespace mysql::sets {
48
49/// Given a class template of the same shape as std::map (four class arguments
50/// for key, mapped, compare, and allocator), and an Ordered set traits class,
51/// provides the specialization with parameters derived from the set traits.
52template <template <class, class, class, class> class Map_template_t,
53 Is_ordered_set_traits Set_traits_t,
54 class Mapped_t = typename Set_traits_t::Element_t>
55using Map_for_set_traits = Map_template_t<
56 typename Set_traits_t::Element_t, Mapped_t, typename Set_traits_t::Less_t,
58 std::pair<const typename Set_traits_t::Element_t, Mapped_t>>>;
59
60} // namespace mysql::sets
61
62// ==== Type aliases ====
63//
64// The following type aliases (using declarations) define how we compose class
65// templates into commonly used set containers with backing storage based on
66// standard library containers.
67//
68// We recommned to use the wrapper classes below instead: the type signatures of
69// the aliases here contain all class templates and template arguments that they
70// are composed of, which makes compilation errors and stack traces hard to
71// read. The wrapper classes hide those details.
72
74
75/// Throwing Boundary container using std::map as backing storage.
76template <Is_bounded_set_traits Set_traits_t>
79
80/// Throwing Boundary container using std::vector as backing storage.
81template <Is_bounded_set_traits Set_traits_t>
84
85/// Throwing Interval container using std::map as backing storage.
86template <Is_bounded_set_traits Set_traits_t>
89
90/// Throwing Interval container using std::vector as backing storage.
91template <Is_bounded_set_traits Set_traits_t>
94
95} // namespace mysql::sets::throwing::detail
96
98
99/// Boundary container using std::map as backing storage.
100template <Is_bounded_set_traits Set_traits_t>
103
104/// Boundary container using std::vector as backing storage.
105template <Is_bounded_set_traits Set_traits_t>
108
109/// Interval container using std::map as backing storage.
110template <Is_bounded_set_traits Set_traits_t>
113
114/// Interval container using std::vector as backing storage.
115template <Is_bounded_set_traits Set_traits_t>
118
119/// Nested set container using std::map as backing storage.
120template <Is_ordered_set_traits Key_traits_t, Is_set Mapped_t>
122 Nested_set_traits<Key_traits_t, typename Mapped_t::Set_traits_t,
123 typename Mapped_t::Set_category_t>,
125
126} // namespace mysql::sets::detail
127
128// ==== Wrapper classes ====
129//
130// The following classes define set containers with standard library containers
131// as backing storage.
132//
133// They are defined based on the type aliases above. We recommend using these
134// wrapper classes instead of the type aliases, because the type signatures of
135// the aliases contain all the class templates and template arguments they are
136// composed of, whereas these wrapper classes hide those details.
137
138namespace mysql::sets::throwing {
139
140/// Throwing Boundary container using std::map as backing storage.
141template <Is_bounded_set_traits Set_traits_tp>
143 : public detail::Map_boundary_container_alias<Set_traits_tp> {
146
147 public:
148 template <class... Args_t>
149 requires mysql::meta::Not_decayed<This_t, Args_t...>
150 explicit Map_boundary_container(Args_t &&...args) noexcept(
151 noexcept(Base_t(std::forward<Args_t>(args)...)))
152 : Base_t(std::forward<Args_t>(args)...) {}
153
154 template <Is_boundary_set_over_traits_unqualified<Set_traits_tp> Other_t>
155 auto &operator=(Other_t &&other) noexcept(
156 noexcept(this->assign(std::forward<Other_t>(other)))) {
157 this->assign(std::forward<Other_t>(other));
158 return *this;
159 }
160};
161
162/// Throwing Boundary container using std::vector as backing storage.
163template <Is_bounded_set_traits Set_traits_tp>
165 : public detail::Vector_boundary_container_alias<Set_traits_tp> {
168
169 public:
170 template <class... Args_t>
171 requires mysql::meta::Not_decayed<This_t, Args_t...>
172 explicit Vector_boundary_container(Args_t &&...args) noexcept(
173 noexcept(Base_t(std::forward<Args_t>(args)...)))
174 : Base_t(std::forward<Args_t>(args)...) {}
175
176 template <Is_boundary_set_over_traits_unqualified<Set_traits_tp> Other_t>
177 auto &operator=(Other_t &&other) noexcept(
178 noexcept(this->assign(std::forward<Other_t>(other)))) {
179 this->assign(std::forward<Other_t>(other));
180 return *this;
181 }
182};
183
184/// Throwing Interval container using std::map as backing storage.
185template <Is_bounded_set_traits Set_traits_tp>
187 : public detail::Map_interval_container_alias<Set_traits_tp> {
190
191 public:
192 template <class... Args_t>
193 requires mysql::meta::Not_decayed<This_t, Args_t...>
194 explicit Map_interval_container(Args_t &&...args) noexcept(
195 noexcept(Base_t(std::forward<Args_t>(args)...)))
196 : Base_t(std::forward<Args_t>(args)...) {}
197
198 template <Is_interval_set_over_traits_unqualified<Set_traits_tp> Other_t>
199 auto &operator=(Other_t &&other) noexcept(
200 noexcept(this->assign(std::forward<Other_t>(other)))) {
201 this->assign(std::forward<Other_t>(other));
202 return *this;
203 }
204};
205
206/// Throwing Interval container using std::vector as backing storage.
207template <Is_bounded_set_traits Set_traits_tp>
209 : public detail::Vector_interval_container_alias<Set_traits_tp> {
212
213 public:
214 template <class... Args_t>
215 requires mysql::meta::Not_decayed<This_t, Args_t...>
216 explicit Vector_interval_container(Args_t &&...args) noexcept(
217 noexcept(Base_t(std::forward<Args_t>(args)...)))
218 : Base_t(std::forward<Args_t>(args)...) {}
219
220 template <Is_interval_set_over_traits_unqualified<Set_traits_tp> Other_t>
221 auto &operator=(Other_t &&other) noexcept(
222 noexcept(this->assign(std::forward<Other_t>(other)))) {
223 this->assign(std::forward<Other_t>(other));
224 return *this;
225 }
226};
227
228} // namespace mysql::sets::throwing
229
230namespace mysql::sets {
231
232/// Boundary container using std::map as backing storage.
233template <Is_bounded_set_traits Set_traits_tp>
235 : public detail::Map_boundary_container_alias<Set_traits_tp> {
238
239 public:
240 template <class... Args_t>
241 requires mysql::meta::Not_decayed<This_t, Args_t...>
242 explicit Map_boundary_container(Args_t &&...args) noexcept
243 : Base_t(std::forward<Args_t>(args)...) {}
244};
245
246/// Boundary container using std::vector as backing storage.
247template <Is_bounded_set_traits Set_traits_tp>
249 : public detail::Vector_boundary_container_alias<Set_traits_tp> {
252
253 public:
254 template <class... Args_t>
255 requires mysql::meta::Not_decayed<This_t, Args_t...>
256 explicit Vector_boundary_container(Args_t &&...args) noexcept
257 : Base_t(std::forward<Args_t>(args)...) {}
258};
259
260/// Interval container using std::map as backing storage.
261template <Is_bounded_set_traits Set_traits_tp>
263 : public detail::Map_interval_container_alias<Set_traits_tp> {
266
267 public:
268 template <class... Args_t>
269 requires mysql::meta::Not_decayed<This_t, Args_t...>
270 explicit Map_interval_container(Args_t &&...args) noexcept
271 : Base_t(std::forward<Args_t>(args)...) {}
272};
273
274/// Interval container using std::vector as backing storage.
275template <Is_bounded_set_traits Set_traits_tp>
277 : public detail::Vector_interval_container_alias<Set_traits_tp> {
280
281 public:
282 template <class... Args_t>
283 requires mysql::meta::Not_decayed<This_t, Args_t...>
284 explicit Vector_interval_container(Args_t &&...args) noexcept
285 : Base_t(std::forward<Args_t>(args)...) {}
286};
287
288/// Nested set container using std::map as backing storage.
289template <Is_ordered_set_traits Key_traits_tp, Is_set Mapped_tp>
291 : public detail::Map_nested_container_alias<Key_traits_tp, Mapped_tp> {
294
295 public:
296 template <class... Args_t>
297 requires mysql::meta::Not_decayed<This_t, Args_t...>
298 explicit Map_nested_container(Args_t &&...args) noexcept
299 : Base_t(std::forward<Args_t>(args)...) {}
300};
301
302} // namespace mysql::sets
303
304// addtogroup GroupLibsMysqlSets
305/// @}
306
307#endif // ifndef MYSQL_SETS_ALIASES_H
Experimental API header.
Allocator using a Memory_resource to do the allocation.
Definition: allocator.h:52
CRTP base class to provide members of a collection based on an implementation that provides begin/end...
Definition: collection_interface.h:90
Container for intervals.
Definition: interval_container.h:49
auto assign(Source_t &&source)
Overwrite this object with source (copy-assigned).
Boundary container using std::map as backing storage.
Definition: aliases.h:235
Map_boundary_container(Args_t &&...args) noexcept
Definition: aliases.h:242
Map_boundary_container< Set_traits_tp > This_t
Definition: aliases.h:237
detail::Map_boundary_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:236
Interval container using std::map as backing storage.
Definition: aliases.h:263
Map_interval_container(Args_t &&...args) noexcept
Definition: aliases.h:270
Map_interval_container< Set_traits_tp > This_t
Definition: aliases.h:265
detail::Map_interval_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:264
Nested set container using std::map as backing storage.
Definition: aliases.h:291
Map_nested_container(Args_t &&...args) noexcept
Definition: aliases.h:298
Map_nested_container< Key_traits_tp, Mapped_tp > This_t
Definition: aliases.h:293
detail::Map_nested_container_alias< Key_traits_tp, Mapped_tp > Base_t
Definition: aliases.h:292
Storage for nested sets, backed by a std::map.
Definition: map_nested_storage.h:66
Represents the subset of a Cartesian product "L x R" of two sets, using a map data structure that map...
Definition: nested_container.h:58
Non-throwing container that stores boundaries.
Definition: nonthrowing_boundary_container_adaptor.h:56
Boundary container using std::vector as backing storage.
Definition: aliases.h:249
Vector_boundary_container(Args_t &&...args) noexcept
Definition: aliases.h:256
Vector_boundary_container< Set_traits_tp > This_t
Definition: aliases.h:251
detail::Vector_boundary_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:250
Interval container using std::vector as backing storage.
Definition: aliases.h:277
Vector_interval_container(Args_t &&...args) noexcept
Definition: aliases.h:284
detail::Vector_interval_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:278
Vector_interval_container< Set_traits_tp > This_t
Definition: aliases.h:279
Container that stores boundaries.
Definition: boundary_container.h:65
void assign(Source_t &&source)
Definition: boundary_container.h:151
Throwing Boundary container using std::map as backing storage.
Definition: aliases.h:143
Map_boundary_container< Set_traits_tp > This_t
Definition: aliases.h:145
detail::Map_boundary_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:144
Map_boundary_container(Args_t &&...args) noexcept(noexcept(Base_t(std::forward< Args_t >(args)...)))
Definition: aliases.h:150
auto & operator=(Other_t &&other) noexcept(noexcept(this->assign(std::forward< Other_t >(other))))
Definition: aliases.h:155
Storage for boundary points, backed by a std::map.
Definition: map_boundary_storage.h:164
Throwing Interval container using std::map as backing storage.
Definition: aliases.h:187
detail::Map_interval_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:188
auto & operator=(Other_t &&other) noexcept(noexcept(this->assign(std::forward< Other_t >(other))))
Definition: aliases.h:199
Map_interval_container(Args_t &&...args) noexcept(noexcept(Base_t(std::forward< Args_t >(args)...)))
Definition: aliases.h:194
Map_interval_container< Set_traits_tp > This_t
Definition: aliases.h:189
Throwing Boundary container using std::vector as backing storage.
Definition: aliases.h:165
detail::Vector_boundary_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:166
Vector_boundary_container< Set_traits_tp > This_t
Definition: aliases.h:167
Vector_boundary_container(Args_t &&...args) noexcept(noexcept(Base_t(std::forward< Args_t >(args)...)))
Definition: aliases.h:172
auto & operator=(Other_t &&other) noexcept(noexcept(this->assign(std::forward< Other_t >(other))))
Definition: aliases.h:177
Throwing Interval container using std::vector as backing storage.
Definition: aliases.h:209
Vector_interval_container(Args_t &&...args) noexcept(noexcept(Base_t(std::forward< Args_t >(args)...)))
Definition: aliases.h:216
detail::Vector_interval_container_alias< Set_traits_tp > Base_t
Definition: aliases.h:210
auto & operator=(Other_t &&other) noexcept(noexcept(this->assign(std::forward< Other_t >(other))))
Definition: aliases.h:221
Vector_interval_container< Set_traits_tp > This_t
Definition: aliases.h:211
false if Args is exactly one type, say A, and std::decay_t<A> equals Type.
Definition: not_decayed.h:84
Experimental API header.
Experimental API header.
Experimental API header.
Definition: aliases.h:97
Definition: aliases.h:73
Definition: aliases.h:73
Definition: gtid_set.h:183
Map_template_t< typename Set_traits_t::Element_t, Mapped_t, typename Set_traits_t::Less_t, mysql::allocators::Allocator< std::pair< const typename Set_traits_t::Element_t, Mapped_t > > > Map_for_set_traits
Given a class template of the same shape as std::map (four class arguments for key,...
Definition: aliases.h:58
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
Experimental API header.
Experimental API header.
Experimental API header.
Experimental API header.
Experimental API header.
Set traits for Nested sets.
Definition: nested_set_traits.h:48
Experimental API header.