MySQL 9.6.0
Source Code Documentation
boundary_set_binary_operation_view_base.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_BINARY_OPERATION_VIEW_BASE_H
25#define MYSQL_SETS_BOUNDARY_SET_BINARY_OPERATION_VIEW_BASE_H
26
27/// @file
28/// Experimental API header
29
30#include "mysql/meta/is_same_ignore_const.h" // Is_same_ignore_const
31#include "mysql/sets/boundary_set_binary_operation_iterator.h" // Boundary_set_binary_operation_iterator
32#include "mysql/sets/boundary_set_interface.h" // Boundary_view_interface
33#include "mysql/sets/boundary_set_meta.h" // Is_boundary_set
34#include "mysql/sets/optional_view_source_set.h" // Optional_view_source_set
35#include "mysql/sets/set_categories_and_traits.h" // Is_compatible_set
36
37/// @addtogroup GroupLibsMysqlSets
38/// @{
39
40namespace mysql::sets::detail {
41
42/// Common base class for the specializations of Union_view, Intersection_view,
43/// and Subtraction_view for boundary sets.
44///
45/// This provides forward iterators.
46///
47/// @tparam Source1_tp Type of the left boundary set.
48///
49/// @tparam Source2_tp Type of the left boundary set.
50///
51/// @tparam operation_tp The type of binary set operation.
52template <Is_boundary_set Source1_tp, Is_boundary_set Source2_tp,
53 Binary_operation operation_tp>
54 requires Is_compatible_set<Source1_tp, Source2_tp>
56 : public Boundary_view_interface<Boundary_set_binary_operation_view_base<
57 Source1_tp, Source2_tp, operation_tp>,
58 Boundary_set_binary_operation_iterator<
59 Source1_tp, Source2_tp, operation_tp>,
60 Boundary_set_binary_operation_iterator<
61 Source1_tp, Source2_tp, operation_tp>,
62 typename Source1_tp::Set_traits_t> {
63 public:
64 using Source1_t = Source1_tp;
65 using Source2_t = Source2_tp;
68 static constexpr auto operation = operation_tp;
70 operation_tp>;
73 using Set_traits_t = typename Source1_t::Set_traits_t;
74 using Element_t = Set_traits_t::Element_t;
75 using Iterator_t =
77 static constexpr bool disable_fast_size = true;
78
79 /// Construct a new, empty view.
81
82 /// Construct a new view over the given boundary set sources.
83 ///
84 /// @param source1 The first source.
85 ///
86 /// @param source2 The second source.
90
91 /// Construct a new view over the given boundary set sources.
92 ///
93 /// Use this constructor if one of the sources may be empty and you do not
94 /// have an object representing it; then pass nullptr for that source.
95 ///
96 /// @param source1 The first source, or nullptr for empty set.
97 ///
98 /// @param source2 The second source, or nullptr for empty set.
102
103 // Default rule-of-5.
104
105 /// @return iterator to the first output boundary.
106 [[nodiscard]] auto begin() const {
109 }
110
111 /// @return iterator to sentinel in the output set.
112 [[nodiscard]] auto end() const {
114 m_source2.end());
115 }
116
117 /// For internal use by the CTRP base class only.
118 ///
119 /// @return lower bound for the given element in the given
120 /// Boundary_set_binary_operation_view_base object.
121 template <class Iter_t>
122 [[nodiscard]] static constexpr Iter_t lower_bound_impl(
123 mysql::meta::Is_same_ignore_const<This_t> auto &self, const Iter_t &hint,
124 const Element_t &element) {
125 return Iter_t(self.m_source1.pointer(), self.m_source2.pointer(),
126 self.m_source1.lower_bound(hint.position1(), element),
127 self.m_source2.lower_bound(hint.position2(), element));
128 }
129
130 /// For internal use by the CTRP base class only.
131 ///
132 /// @return upper bound for the given element in the given
133 /// Boundary_set_binary_operation_view_base object.
134 template <class Iter_t>
135 [[nodiscard]] static constexpr Iter_t upper_bound_impl(
136 mysql::meta::Is_same_ignore_const<This_t> auto &self, const Iter_t &hint,
137 const Element_t &element) {
138 return Iter_t(self.m_source1.pointer(), self.m_source2.pointer(),
139 self.m_source1.upper_bound(hint.position1(), element),
140 self.m_source2.upper_bound(hint.position2(), element));
141 }
142
143 /// Return pointer to the first boundary set operand.
144 [[nodiscard]] const Source1_t *source1() const { return m_source1.pointer(); }
145
146 /// Return pointer to the second boundary set operand.
147 [[nodiscard]] const Source2_t *source2() const { return m_source2.pointer(); }
148
149 private:
150 /// Pointer to the first boundary set operand.
152
153 /// Pointer to the second boundary set operand.
155}; // class Boundary_set_binary_operation_view_base over boundary sets
156
157} // namespace mysql::sets::detail
158
159// addtogroup GroupLibsMysqlSets
160/// @}
161
162#endif // ifndef MYSQL_SETS_BOUNDARY_SET_BINARY_OPERATION_VIEW_BASE_H
Experimental API header.
Experimental API header.
auto begin() const
Return a valid begin iterator, even if !has_object().
Definition: view_sources.h:262
const Source_t * pointer() const
Return a pointer to the source if there is one, or nullptr otherwise.
Definition: view_sources.h:242
auto end() const
Return a valid end iterator, even if !has_object().
Definition: view_sources.h:273
CRTP base class/mixin, used to implement Boundary Sets that are views.
Definition: boundary_set_interface.h:106
Forward iterator over the result of a binary set operation (union, intersection, or subtraction) over...
Definition: boundary_set_binary_operation_iterator.h:50
Common base class for the specializations of Union_view, Intersection_view, and Subtraction_view for ...
Definition: boundary_set_binary_operation_view_base.h:62
mysql::ranges::Range_const_iterator_type< Source1_t > Iterator1_t
Definition: boundary_set_binary_operation_view_base.h:71
static constexpr Iter_t lower_bound_impl(mysql::meta::Is_same_ignore_const< This_t > auto &self, const Iter_t &hint, const Element_t &element)
For internal use by the CTRP base class only.
Definition: boundary_set_binary_operation_view_base.h:122
static constexpr auto operation
Definition: boundary_set_binary_operation_view_base.h:68
Source1_tp Source1_t
Definition: boundary_set_binary_operation_view_base.h:64
Boundary_set_binary_operation_iterator< Source1_t, Source2_t, operation > Iterator_t
Definition: boundary_set_binary_operation_view_base.h:76
const Source1_t * source1() const
Return pointer to the first boundary set operand.
Definition: boundary_set_binary_operation_view_base.h:144
static constexpr Iter_t upper_bound_impl(mysql::meta::Is_same_ignore_const< This_t > auto &self, const Iter_t &hint, const Element_t &element)
For internal use by the CTRP base class only.
Definition: boundary_set_binary_operation_view_base.h:135
Set_traits_t::Element_t Element_t
Definition: boundary_set_binary_operation_view_base.h:74
typename Source1_t::Set_traits_t Set_traits_t
Definition: boundary_set_binary_operation_view_base.h:73
Opt_source2_t m_source2
Pointer to the second boundary set operand.
Definition: boundary_set_binary_operation_view_base.h:154
mysql::ranges::Range_const_iterator_type< Source2_t > Iterator2_t
Definition: boundary_set_binary_operation_view_base.h:72
auto end() const
Definition: boundary_set_binary_operation_view_base.h:112
auto begin() const
Definition: boundary_set_binary_operation_view_base.h:106
Source2_tp Source2_t
Definition: boundary_set_binary_operation_view_base.h:65
static constexpr bool disable_fast_size
Definition: boundary_set_binary_operation_view_base.h:77
Boundary_set_binary_operation_view_base(const Source1_t *source1, const Source2_t *source2) noexcept
Construct a new view over the given boundary set sources.
Definition: boundary_set_binary_operation_view_base.h:99
const Source2_t * source2() const
Return pointer to the second boundary set operand.
Definition: boundary_set_binary_operation_view_base.h:147
Boundary_set_binary_operation_view_base() noexcept=default
Construct a new, empty view.
Opt_source1_t m_source1
Pointer to the first boundary set operand.
Definition: boundary_set_binary_operation_view_base.h:151
true if Type1 and Type2 are equal, const-ness ignored
Definition: is_same_ignore_const.h:39
Experimental API header.
std::remove_cvref_t< decltype(std::declval< const Range_t >().begin())> Range_const_iterator_type
Gives the const_iterator type, deduced from the begin() const member.
Definition: meta.h:47
Definition: aliases.h:97
Binary_operation
Identifies the type of a binary operation.
Definition: binary_operation.h:37
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.