MySQL 9.6.0
Source Code Documentation
basic_set_container_wrapper.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_BASIC_SET_CONTAINER_WRAPPER_H
25#define MYSQL_SETS_BASIC_SET_CONTAINER_WRAPPER_H
26
27/// @file
28/// Experimental API header
29
30#include <type_traits> // remove_cvref_t
31#include <utility> // move
32#include "mysql/containers/basic_container_wrapper.h" // Basic_container_wrapper
33#include "mysql/sets/meta.h" // Can_donate_set
34#include "mysql/sets/set_categories_and_traits.h" // Is_compatible_set
35#include "mysql/utils/is_same_object.h" // is_same_object
36
37/// @addtogroup GroupLibsMysqlSets
38/// @{
39
40namespace mysql::sets {
41
42template <class Self_tp, class Wrapped_tp,
43 mysql::utils::Shall_catch shall_catch_tp =
44 mysql::utils::Shall_catch::no>
46 : public mysql::containers::Basic_container_wrapper<Self_tp, Wrapped_tp,
47 shall_catch_tp> {
49 shall_catch_tp>;
50 using This_t =
52
53 public:
54 template <class... Args_t>
55 explicit Basic_set_container_wrapper(Args_t &&...args)
56 : Base_t(std::forward<Args_t>(args)...) {}
57
58 using Base_t::assign;
59
60 /// Enable move-assign from any Basic_set_container_wrapper for a compatible
61 /// set type (not necessarily for a derived class).
62 template <class Source_t>
64 Wrapped_tp>
65 // The requires clause ensures that Source_t is an rvalue reference.
66 // NOLINTNEXTLINE(cppcoreguidelines-missing-std-forward)
67 void assign(Source_t &&source) {
68 if (mysql::utils::is_same_object(source, *this)) return;
69 // The requires clause ensures that Source_t is an rvalue reference.
70 // NOLINTNEXTLINE(bugprone-move-forwarding-reference)
71 this->wrapped() = std::move(source).wrapped();
72 }
73};
74
75namespace detail {
76
77template <class Source_t, class Target_t>
80 ((
81 // If Source wraps a compatible set, recurse into Source
84 (
85 // If Target wraps a compatible set, recurse into Target
88 // Recurse into both, regardless if they are compatible with the wrappers.
89 Can_donate_set_unqualified<typename Source_t::Wrapped_t,
90 typename Target_t::Wrapped_t>);
91
92} // namespace detail
93
94/// Declare that move-semantics is supported for full-set-copy operations on Set
95/// Container Wrapper types, whenever the wrapped types can be nothrow-moved.
96template <class Source_t, class Target_t>
98struct Enable_donate_set<Source_t, Target_t> : public std::true_type {};
99
100} // namespace mysql::sets
101
102// addtogroup GroupLibsMysqlSets
103/// @}
104
105#endif // ifndef MYSQL_SETS_BASIC_SET_CONTAINER_WRAPPER_H
Experimental API header.
CRTP base class (mixin) to define a wrapper around a container.
Definition: basic_container_wrapper.h:59
auto assign(const First_iterator_t &first, const Sentinel_t &last) noexcept(shall_catch==mysql::utils::Shall_catch::yes||noexcept(std::declval< Wrapped_t >().assign(first, last)))
Assign a range defined by the two iterators to the wrapped object.
Definition: basic_container_wrapper.h:83
Definition: basic_set_container_wrapper.h:47
Basic_set_container_wrapper(Args_t &&...args)
Definition: basic_set_container_wrapper.h:55
void assign(Source_t &&source)
Enable move-assign from any Basic_set_container_wrapper for a compatible set type (not necessarily fo...
Definition: basic_set_container_wrapper.h:67
True if move-semantics has been declared as enabled for full-set-copy operations for the given operan...
Definition: meta.h:83
True if move-semantics has been declared as enabled for full-set-copy operations for the given operan...
Definition: meta.h:90
True if Set1_t and Set2_t have the same Set_category_t and Set_traits_t.
Definition: set_categories_and_traits.h:77
Definition: basic_set_container_wrapper.h:78
Experimental API header.
Experimental API header.
Definition: fts0fts.cc:236
Definition: gtid_set.h:183
bool is_same_object(const Obj1_t &obj1, const Obj2_t &obj2)
Return true if the types of the two objects are either equal or one derived from the other,...
Definition: is_same_object.h:40
Define std::hash<Gtid>.
Definition: gtid.h:355
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
Experimental API header.
Customization point that set container types can use to indicate that they support noexcept move-sema...
Definition: meta.h:74