24#ifndef MYSQL_SETS_UPPER_LOWER_BOUND_INTERFACE_H
25#define MYSQL_SETS_UPPER_LOWER_BOUND_INTERFACE_H
41template <
class Test,
class Iterator_t,
class Element_t>
43 requires(Test test, Iterator_t hint, Element_t element) {
45 Test::lower_bound_impl(test, hint, element)
46 } -> std::same_as<Iterator_t>;
50template <
class Test,
class Iterator_t,
class Element_t>
52 requires(Test test, Element_t element) {
53 { Test::lower_bound_impl(test, element) } -> std::same_as<Iterator_t>;
57template <
class Test,
class Iterator_t,
class Element_t>
63template <
class Test,
class Iterator_t,
class Element_t>
65 requires(Test test, Iterator_t hint, Element_t element) {
67 Test::upper_bound_impl(test, hint, element)
68 } -> std::same_as<Iterator_t>;
72template <
class Test,
class Iterator_t,
class Element_t>
74 requires(Test test, Element_t element) {
75 { Test::upper_bound_impl(test, element) } -> std::same_as<Iterator_t>;
79template <
class Test,
class Iterator_t,
class Element_t>
98template <
class Test,
class Iterator_t>
100 requires(Iterator_t iterator) {
Test::get(iterator); };
104 [[nodiscard]]
static decltype(
auto)
get(
105 const std::input_iterator
auto &iterator) {
112 [[nodiscard]]
static const auto &
get(
113 const std::input_iterator
auto &iterator) {
114 return iterator->first;
157template <
class Test,
class Iterator_t,
class Const_iterator_t,
class Element_t>
159 std::forward_iterator<Iterator_t> &&
160 std::forward_iterator<Const_iterator_t> &&
161 requires(Test implementation,
const Test const_implementation,
162 Iterator_t iterator, Const_iterator_t const_iterator,
164 { implementation.begin() } -> std::same_as<Iterator_t>;
165 { implementation.end() } -> std::same_as<Iterator_t>;
166 { const_implementation.begin() } -> std::same_as<Const_iterator_t>;
167 { const_implementation.end() } -> std::same_as<Const_iterator_t>;
190 std::forward_iterator Iterator_tp,
191 std::forward_iterator Const_iterator_tp,
337 template <std::derived_from<Self_t> Self_arg_t,
338 mysql::ranges::Is_iterator_for_range<Self_arg_t> Iter_t>
340 Self_arg_t &self_arg,
const Iter_t &hint,
const Element_t &element) {
341 if (hint == self_arg.end() ||
346 return Self_arg_t::lower_bound_impl(self_arg, hint, element);
348 return Self_arg_t::lower_bound_impl(self_arg, element);
353 template <std::derived_from<Self_t> Self_arg_t>
355 Self_arg_t &self_arg,
const Element_t &element) {
360 return Self_arg_t::lower_bound_impl(self_arg, element);
362 return Self_arg_t::lower_bound_impl(self_arg, self_arg.begin(), element);
369 template <std::derived_from<Self_t> Self_arg_t,
370 mysql::ranges::Is_iterator_for_range<Self_arg_t> Iter_t>
372 Self_arg_t &self_arg,
const Iter_t &hint,
const Element_t &element) {
373 if (hint == self_arg.end() ||
378 return Self_arg_t::upper_bound_impl(self_arg, hint, element);
380 return Self_arg_t::upper_bound_impl(self_arg, element);
385 template <std::derived_from<Self_t> Self_arg_t>
387 Self_arg_t &self_arg,
const Element_t &element) {
392 return Self_arg_t::upper_bound_impl(self_arg, element);
394 return Self_arg_t::upper_bound_impl(self_arg, self_arg.begin(), element);
401 [[nodiscard]]
constexpr const Self_t &
self()
const {
405 return static_cast<const Self_t &
>(*this);
411 return static_cast<Self_t &
>(*this);
CRTP base class (mixin) to define a set that has upper_bound and lower_bound members.
Definition: upper_lower_bound_interface.h:193
Iterator_getter_tp Iterator_getter_t
Definition: upper_lower_bound_interface.h:200
constexpr Iterator_t lower_bound(const Iterator_t &hint, const Element_t &element)
Return the lower bound for element, using an iterator hint known to be less than or equal to the corr...
Definition: upper_lower_bound_interface.h:219
constexpr Const_iterator_t lower_bound(const Element_t &element) const
Return the lower bound for element.
Definition: upper_lower_bound_interface.h:264
Const_iterator_tp Const_iterator_t
Definition: upper_lower_bound_interface.h:198
static constexpr auto lower_bound_dispatch(Self_arg_t &self_arg, const Element_t &element)
Implements the lower_bound functions without hint defined above.
Definition: upper_lower_bound_interface.h:354
static constexpr Iter_t upper_bound_dispatch(Self_arg_t &self_arg, const Iter_t &hint, const Element_t &element)
Implements the upper_bound functions with hint defined above, checking if the hint is already the cor...
Definition: upper_lower_bound_interface.h:371
typename Set_traits_t::Element_t Element_t
Definition: upper_lower_bound_interface.h:202
constexpr Iterator_t upper_bound(const Iterator_t &hint, const Element_t &element)
Return the upper bound for element, using an iterator hint known to be less than or equal to the corr...
Definition: upper_lower_bound_interface.h:284
Self_tp Self_t
Definition: upper_lower_bound_interface.h:194
static constexpr auto upper_bound_dispatch(Self_arg_t &self_arg, const Element_t &element)
Implements the upper_bound functions without hint defined above.
Definition: upper_lower_bound_interface.h:386
constexpr Const_iterator_t upper_bound(const Const_iterator_t &hint, const Element_t &element) const
Return the upper bound for element, using an iterator hint known to be less than or equal to the corr...
Definition: upper_lower_bound_interface.h:304
Iterator_tp Iterator_t
Definition: upper_lower_bound_interface.h:197
constexpr Const_iterator_t upper_bound(const Element_t &element) const
Return the upper bound for element.
Definition: upper_lower_bound_interface.h:329
static constexpr Iter_t lower_bound_dispatch(Self_arg_t &self_arg, const Iter_t &hint, const Element_t &element)
Implements the lower_bound functions with hint defined above, checking if the hint is already the cor...
Definition: upper_lower_bound_interface.h:339
constexpr Iterator_t lower_bound(const Element_t &element)
Return the lower bound for element.
Definition: upper_lower_bound_interface.h:252
Set_traits_tp Set_traits_t
Definition: upper_lower_bound_interface.h:199
constexpr Const_iterator_t lower_bound(const Const_iterator_t &hint, const Element_t &element) const
Return the lower bound for element, using an iterator hint known to be less than or equal to the corr...
Definition: upper_lower_bound_interface.h:239
constexpr Iterator_t upper_bound(const Element_t &element)
Return the upper bound for element.
Definition: upper_lower_bound_interface.h:317
True if Test is a getter for Iterator_t, i.e., Test::get(Iterator_t) is defined.
Definition: upper_lower_bound_interface.h:99
True if Test is an "ordered" Set traits class.
Definition: set_traits.h:88
True if Test satisfies the requirements for being a subclass of Upper_lower_bound_interface.
Definition: upper_lower_bound_interface.h:158
True if Test::lower_bound_impl(test, hint, element) is defined.
Definition: upper_lower_bound_interface.h:42
True if Test::lower_bound_impl(test, element) is defined.
Definition: upper_lower_bound_interface.h:51
True if one of the lower bound functions is defined.
Definition: upper_lower_bound_interface.h:58
True if Test::upper_bound_impl(test, hint, element) is defined.
Definition: upper_lower_bound_interface.h:64
True if Test::upper_bound_impl(test, element) is defined.
Definition: upper_lower_bound_interface.h:73
True if one of the upper bound functions is defined.
Definition: upper_lower_bound_interface.h:80
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: gtid_set.h:183
static mysql_service_status_t get(THD **thd) noexcept
Definition: mysql_current_thread_reader_all_empty.cc:31
Iterator getter that returns iterator->first.
Definition: upper_lower_bound_interface.h:111
static const auto & get(const std::input_iterator auto &iterator)
Definition: upper_lower_bound_interface.h:112
Iterator getter that returns *iterator.
Definition: upper_lower_bound_interface.h:103
static decltype(auto) get(const std::input_iterator auto &iterator)
Definition: upper_lower_bound_interface.h:104