MySQL 9.6.0
Source Code Documentation
boundary_set_interface.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_BOUNDARY_SET_INTERFACE_H
25#define MYSQL_SETS_BOUNDARY_SET_INTERFACE_H
26
27/// @file
28/// Experimental API header
29
30/// @addtogroup GroupLibsMysqlSets
31/// @{
32
33#include <utility> // forward
34#include "mysql/containers/basic_container_wrapper.h" // Basic_container_wrapper
35#include "mysql/meta/not_decayed.h" // Not_decayed
36#include "mysql/ranges/collection_interface.h" // Collection_interface
37#include "mysql/ranges/meta.h" // Range_iterator_type
38#include "mysql/sets/basic_set_container_wrapper.h" // Basic_set_container_wrapper
39#include "mysql/sets/boundary_set_category.h" // Boundary_set_category_tag
40#include "mysql/sets/boundary_set_meta.h" // Is_boundary_iterator
41#include "mysql/sets/set_traits.h" // Is_bounded_set_traits
42#include "mysql/sets/upper_lower_bound_interface.h" // Upper_lower_bound_interface
43#include "mysql/utils/call_and_catch.h" // Shall_catch
44
45namespace mysql::sets::detail {
46
47/// CRTP base class used to implement Boundary Sets. This defines all the
48/// lower_bound/upper_bound members based on the
49/// lower_bound_impl/upper_bound_impl members in the subclass.
50///
51/// The subclass additionally has to define the view members, e.g. by deriving
52/// from mysql::ranges::Collection_interface or
53/// mysql::containers::Basic_container_wrapper. Doing so will make it satisfy
54/// the mysql::sets::Is_boundary_set concept. As a convenience, use
55/// Boundary_view_interface to inherit both from this class and from
56/// Collection_interface, and use Basic_boundary_container_wrapper to inherit
57/// both this class and from Basic_container_wrapper.
58///
59/// @tparam Self_tp The subclass. This must satisfy
60/// Is_boundary_set_implementation.
61///
62/// @tparam Iterator_tp Iterator type.
63///
64/// @tparam Const_iterator_tp Const iterator type.
65///
66/// @tparam Set_traits_tp Set Traits for the set.
67template <class Self_tp, Is_boundary_iterator Iterator_tp,
68 Is_boundary_iterator Const_iterator_tp,
69 Is_bounded_set_traits Set_traits_tp>
71 : public Upper_lower_bound_interface<Self_tp, Set_traits_tp, Iterator_tp,
72 Const_iterator_tp,
73 Iterator_get_value> {
74 public:
75 using Iterator_t = Iterator_tp;
76 using Const_iterator_t = Const_iterator_tp;
78 using Set_traits_t = Set_traits_tp;
79 using Element_t = typename Set_traits_tp::Element_t;
80}; // class Boundary_set_interface
81
82} // namespace mysql::sets::detail
83
84namespace mysql::sets {
85
86/// CRTP base class/mixin, used to implement Boundary Sets that are *views*.
87/// This defines all the lower_bound and upper_bound members based on
88/// lower_bound_impl and upper_bound_impl members in the subclass, and also
89/// implements all the view members defined by
90/// mysql::ranges::Collection_interface.
91///
92/// @tparam Self_tp Class deriving from this class.
93///
94/// @tparam Iterator_tp Iterator type.
95///
96/// @tparam Const_iterator_tp Const iterator type.
97///
98/// @tparam Set_traits_tp Bounded set traits.
99template <class Self_tp, Is_boundary_iterator Iterator_tp,
100 Is_boundary_iterator Const_iterator_tp,
101 Is_bounded_set_traits Set_traits_tp>
103 : public mysql::ranges::Collection_interface<Self_tp>,
104 public detail::Boundary_set_interface<Self_tp, Iterator_tp,
105 Const_iterator_tp, Set_traits_tp>,
106 public std::ranges::view_base {};
107
108/// CRTP base class/mixin, used to implement Boundary Sets that are *container
109/// wrappers*. This defines all the lower_bound and upper_bound members based on
110/// lower_bound_impl and upper_bound_impl members in the subclass, and also
111/// implements all the container members defined by
112/// mysql::containers::Basic_container_wrapper.
113///
114/// @tparam Self_tp Class deriving from this class.
115///
116/// @tparam Wrapped_tp Type of the wrapped boundary set class.
117///
118/// @tparam shall_catch_tp Whether `assign` should catch bad_alloc
119/// exceptions and convert them to `Return_status` return values.
120template <class Self_tp, class Wrapped_tp,
121 mysql::utils::Shall_catch shall_catch_tp =
122 mysql::utils::Shall_catch::no>
124 : public Basic_set_container_wrapper<Self_tp, Wrapped_tp, shall_catch_tp>,
126 Self_tp, mysql::ranges::Range_iterator_type<Wrapped_tp>,
127 mysql::ranges::Range_const_iterator_type<Wrapped_tp>,
128 typename Wrapped_tp::Set_traits_t> {
131 using This_t =
133
134 public:
135 template <class... Args_t>
136 requires mysql::meta::Not_decayed<This_t, Args_t...>
137 explicit Basic_boundary_container_wrapper(Args_t &&...args)
138 : Basic_set_container_wrapper_t(std::forward<Args_t>(args)...) {}
139
140 // default rule-of-5
144 Basic_boundary_container_wrapper &&source) noexcept = default;
148 Basic_boundary_container_wrapper &&source) noexcept = default;
150};
151
152} // namespace mysql::sets
153
154// addtogroup GroupLibsMysqlSets
155/// @}
156
157#endif // ifndef MYSQL_SETS_BOUNDARY_SET_INTERFACE_H
Experimental API header.
Experimental API header.
Experimental API header.
Experimental API header.
Experimental API header.
CRTP base class (mixin) to define a wrapper around a container.
Definition: basic_container_wrapper.h:59
CRTP base class to provide members of a collection based on an implementation that provides begin/end...
Definition: collection_interface.h:90
CRTP base class/mixin, used to implement Boundary Sets that are container wrappers.
Definition: boundary_set_interface.h:128
Basic_boundary_container_wrapper & operator=(Basic_boundary_container_wrapper &&source) noexcept=default
Basic_boundary_container_wrapper(Basic_boundary_container_wrapper &&source) noexcept=default
Basic_boundary_container_wrapper & operator=(const Basic_boundary_container_wrapper &source)=default
Basic_boundary_container_wrapper(const Basic_boundary_container_wrapper &source)=default
Basic_boundary_container_wrapper< Self_tp, Wrapped_tp, shall_catch_tp > This_t
Definition: boundary_set_interface.h:132
Basic_boundary_container_wrapper(Args_t &&...args)
Definition: boundary_set_interface.h:137
Definition: basic_set_container_wrapper.h:47
CRTP base class/mixin, used to implement Boundary Sets that are views.
Definition: boundary_set_interface.h:106
CRTP base class (mixin) to define a set that has upper_bound and lower_bound members.
Definition: upper_lower_bound_interface.h:193
CRTP base class used to implement Boundary Sets.
Definition: boundary_set_interface.h:73
Iterator_tp Iterator_t
Definition: boundary_set_interface.h:75
Set_traits_tp Set_traits_t
Definition: boundary_set_interface.h:78
typename Set_traits_tp::Element_t Element_t
Definition: boundary_set_interface.h:79
Const_iterator_tp Const_iterator_t
Definition: boundary_set_interface.h:76
Experimental API header.
false if Args is exactly one type, say A, and std::decay_t<A> equals Type.
Definition: not_decayed.h:84
True if Test is a boundary point iterator, i.e.
Definition: boundary_set_meta.h:83
True if Test is a "bounded" Set traits class.
Definition: set_traits.h:105
Experimental API header.
Definition: aliases.h:97
Definition: gtid_set.h:183
Define std::hash<Gtid>.
Definition: gtid.h:355
Experimental API header.
repeated Source source
Definition: replication_asynchronous_connection_failover.proto:42
Experimental API header.
Tag to identify a class as a Boundary set.
Definition: boundary_set_category.h:41
Experimental API header.