MySQL 9.6.0
Source Code Documentation
nested_set_meta.h
Go to the documentation of this file.
1// Copyright (c) 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_NESTED_SET_META_H
25#define MYSQL_SETS_NESTED_SET_META_H
26
27/// @file
28/// Experimental API header
29
30#include <concepts> // same_as
31#include "mysql/ranges/meta.h" // Is_collection_over
32#include "mysql/sets/meta.h" // Enable_donate_set
33#include "mysql/sets/nested_set_category.h" // Nested_set_category_tag
34#include "mysql/sets/set_categories.h" // Base_set_category_tag
36#include "mysql/sets/set_traits.h" // Is_set_traits
37
38/// @addtogroup GroupLibsMysqlSets
39/// @{
40
41namespace mysql::sets {
42
43// ==== Is_nested_set_traits ====
44
45/// True if Test is a Set Traits class for a nested set.
46///
47/// This requires Test is a set traits which has a type member Key_traits_t
48/// which is an ordered set traits, and a type member Mapped_traits_t which is a
49/// set traits, and a type member Mapped_category which is a set category.
50template <class Test>
55
56} // namespace mysql::sets
57
58// ==== Is_nested_set ====
59
60namespace mysql::sets::detail {
61
62/// Common helper for Is_nested_set and Is_nested_storage.
63template <class Test>
66 std::same_as<typename Test::Set_traits_t::Key_traits_t,
67 typename Test::Key_traits_t> &&
68 std::same_as<typename Test::Set_traits_t::Mapped_traits_t,
69 typename Test::Mapped_traits_t> &&
70 std::same_as<typename Test::Set_traits_t::Mapped_category_t,
71 typename Test::Mapped_category_t> &&
72 std::same_as<typename Test::Set_traits_t::Key_traits_t::Element_t,
73 typename Test::Key_t> &&
75 Test, std::pair<const typename Test::Key_t, typename Test::Mapped_t>> &&
76 requires(Test t, const Test ct, typename Test::Key_t k) {
77 { t.find(k) } -> std::same_as<mysql::ranges::Range_iterator_type<Test>>;
78 {
79 ct.find(k)
80 } -> std::same_as<mysql::ranges::Range_const_iterator_type<Test>>;
81 };
82
83} // namespace mysql::sets::detail
84
85namespace mysql::sets {
86
87/// True if Test is a nested set.
88///
89/// Test must have the following type members:
90///
91/// - Set_category_t: equal to Nested_set_category_tag
92/// - Set_traits_t: satisfies Is_nested_set_traits
93/// - Key_traits: equal to Set_traits_t::Key_traits_t
94/// - Mapped_traits_t: equal to Set_traits_t::Mapped_traits_t
95/// - Mapped_category_t: equal to Set_traits_t::Mapped_category_t
96/// - Key_t: equal to Set_traits_t::Key_traits_t::Element_t
97///
98/// Test must also satisfy the following concepts:
99/// - Is_set
100/// - Is_collection_over<pair<Test::Key_t, Test::Mapped_t>>
101/// (which requires a number of member functions; @see Is_collection_over)
102///
103/// Additionally, test must support the following operations:
104///
105/// @code
106/// t[k]; // return the mapped set for key k, if k is a key
107/// t.find(k); // return iterator to the pair with k as key, or to the end
108/// @endcode
109template <class Test>
113 requires(Test t, const Test ct, typename Test::Key_t k) {
114 {
115 t[k]
117 typename Test::Set_traits_t::Mapped_category_t,
118 typename Test::Set_traits_t::Mapped_traits_t>;
119 {
120 ct[k]
122 typename Test::Set_traits_t::Mapped_category_t,
123 typename Test::Set_traits_t::Mapped_traits_t>;
124 };
125
126/// True if Test satisfies Is_nested_set and its traits is Set_traits_t.
127template <class Test, class Set_traits_t>
130
131// True if std::remove_cvref_t<Test> satisfies
132// Is_nested_set_over_traits<Set_traits_t>.
133template <class Test, class Set_traits_t>
136
137// ==== Is_nested_storage ====
138
139/// True if Test is a Nested Set Storage.
140///
141/// This is similar to Is_nested_set, with the following exceptions:
142/// - This does not have to satisfy Is_set
143/// - This does not require member Set_category_t
144/// - This does not require subscript operator
145/// - This requires the following members:
146/// @code
147/// t.clear(); // make the set empty
148/// t.emplace(k); // insert element with the given key and empty mapped set
149/// t.emplace(it, k); // similar, with an iterator hint
150/// t.erase(it); // remove element pointed to by iterator
151/// typename Test::Container_t // type of underlying container
152/// @endcode
153template <class Test>
156 requires(Test t, const Test ct, typename Test::Key_t k,
158 t.assign(ct);
159 t.clear();
160 t.emplace(k);
161 t.emplace(it, k);
162 { t.erase(it) } -> std::same_as<mysql::ranges::Range_iterator_type<Test>>;
163 };
164
165/// True if Test is a Nested Storage and its traits equals Set_traits_t.
166template <class Test, class Set_traits_t>
169
170// True if Test is a Nested Container.
171template <class Test>
174 requires(Test t, Test ct, typename Test::Key_t k, typename Test::Mapped_t m,
176 t.clear();
177 t.assign(t);
178
179 t.inplace_union(t);
180 t.inplace_union(k, m);
181
182 t.inplace_intersect(t);
183 t.inplace_intersect(k, m);
184 t.inplace_intersect(k);
185
186 t.inplace_subtract(t);
187 t.inplace_subtract(k, m);
188 t.inplace_subtract(k);
189 t.inplace_subtract(it, k);
190 };
191
192// ==== Enable_donate_set[_elements] ====
193
194namespace detail {
195
196/// Helper concept to define the condition when Enable_donate_set_elements shall
197/// be defined for Nested Storage types.
198template <class Source_t, class Target_t>
201 requires(Source_t source, Target_t target,
204 {
205 target.steal_and_insert(target_it, source, source_it)
206 } noexcept
207 -> std::same_as<mysql::ranges::Range_iterator_type<Target_t>>;
208 } &&
209 Can_donate_set_elements_unqualified<typename Source_t::Mapped_t,
210 typename Target_t::Mapped_t>;
211
212/// Helper concept to define the condition when Enable_donate_set_elements shall
213/// be defined for Nested Container types.
214template <class Source_t, class Target_t>
217 Can_donate_set_elements_unqualified<typename Source_t::Storage_t,
218 typename Target_t::Storage_t>;
219
220} // namespace detail
221
222/// Declare that move-semantics is supported for element operations on Nested
223/// Storage types, whenever full-set-copy is enabled and the function
224/// `steal_and_insert` is defined.
225template <class Source_t, class Target_t>
227 Target_t>
228struct Enable_donate_set_elements<Source_t, Target_t> : public std::true_type {
229};
230
231/// Declare that move-semantics is supported for element operations on
232/// compatible Nested Set container types, whenever the storage supports it,
233/// and full-set-copy is enabled.
234template <class Source_t, class Target_t>
236 Source_t, Target_t>
237struct Enable_donate_set_elements<Source_t, Target_t> : public std::true_type {
238};
239
240} // namespace mysql::sets
241
242// addtogroup GroupLibsMysqlSets
243/// @}
244
245#endif // ifndef MYSQL_SETS_NESTED_SET_META_H
True if Test models Is_collection, with Value_t as its value type.
Definition: meta.h:131
True if move-semantics has been declared as enabled for inplace_union/inplace_intersect/inplace_subtr...
Definition: meta.h:107
True if Test has a member Set_category_t satisfying Is_set_category.
Definition: set_categories.h:55
True if Test has a member Set_traits_t.
Definition: set_traits.h:59
Definition: nested_set_meta.h:172
True if Test satisfies Is_nested_set and its traits is Set_traits_t.
Definition: nested_set_meta.h:128
True if Test is a Set Traits class for a nested set.
Definition: nested_set_meta.h:51
True if Test is a nested set.
Definition: nested_set_meta.h:110
True if Test is a Nested Storage and its traits equals Set_traits_t.
Definition: nested_set_meta.h:167
True if Test is a Nested Set Storage.
Definition: nested_set_meta.h:154
True if Test is an "ordered" Set traits class.
Definition: set_traits.h:88
True if Test is a Set category tag, i.e., derived from Base_set_category_tag.
Definition: set_categories.h:48
True if Test is a reference to a set with category Category_t and traits Traits_t.
Definition: set_categories_and_traits.h:69
True if Test is a Set_traits class, i.e., is derived from Base_set_traits.
Definition: set_traits.h:50
True if Test is a set.
Definition: set_categories_and_traits.h:62
Common helper for Is_nested_set and Is_nested_storage.
Definition: nested_set_meta.h:64
Helper concept to define the condition when Enable_donate_set_elements shall be defined for Nested Co...
Definition: nested_set_meta.h:215
Helper concept to define the condition when Enable_donate_set_elements shall be defined for Nested St...
Definition: nested_set_meta.h:199
Experimental API header.
Experimental API header.
Definition: fts0fts.cc:236
std::remove_cvref_t< decltype(std::declval< Range_t >().begin())> Range_iterator_type
Gives the iterator type, deduced from the begin() member.
Definition: meta.h:42
Definition: aliases.h:97
Definition: gtid_set.h:183
Experimental API header.
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
Experimental API header.
Experimental API header.
Experimental API header.
Customization point that set container types can use to indicate that they support noexcept move-sema...
Definition: meta.h:101