24#ifndef MYSQL_SETS_INTERVAL_H
25#define MYSQL_SETS_INTERVAL_H
52template <Is_bounded_set_traits Set_traits_tp>
121template <Is_bounded_set_traits Set_traits_tp>
139template <Is_bounded_set_traits Set_traits_tp>
147 template <
class... Args_t>
150 :
Base_t(
std::forward<Args_t>(args)...) {}
177template <Is_bounded_set_traits Set_traits_tp>
203 :
Base_t(start_arg, exclusive_end_arg) {
226 return Interval(start_arg, exclusive_end_arg);
249 assert_consistent<Check_start::yes, Check_end::no>(start_arg,
258 assert_consistent<Check_start::no, Check_end::yes>(this->
start(),
269 return mysql::utils::call_and_catch(
287 return mysql::utils::call_and_catch(
303 if (!Set_traits_t::le(Set_traits_t::min(), start_arg)) {
304 throw std::domain_error{
"Out-of-range: start < minimum"};
307 if (!Set_traits_t::lt(start_arg, exclusive_end_arg)) {
308 throw std::domain_error{
"Out-of-order: end <= start"};
311 if (!Set_traits_t::le(exclusive_end_arg, Set_traits_t::max_exclusive())) {
312 throw std::domain_error{
"Out-of-range: end > maximum"};
Holds the start boundary and endpoint boundary of an interval.
Definition: interval.h:178
Return_status_t set_start(const Element_t &start_arg)
Set the start to the given value.
Definition: interval.h:277
void throwing_set_start(const Element_t &start_arg)
Set the start to the given value.
Definition: interval.h:248
Return_status_t set_exclusive_end(const Element_t &exclusive_end_arg)
Set the exclusive end to the given value.
Definition: interval.h:285
Check_end
Whether assert_consistent needs to check the end boundary.
Definition: interval.h:193
Interval(const Element_t &start_arg, const Element_t &exclusive_end_arg)
Construct an interval with the given values for start and exclusive end.
Definition: interval.h:201
Check_start
Whether assert_consistent needs to check the start boundary.
Definition: interval.h:190
Interval()
Definition: interval.h:217
Return_status_t assign(const Element_t &start_arg, const Element_t &exclusive_end_arg)
Set the start and exclusive end to the given values.
Definition: interval.h:267
void throwing_set_exclusive_end(const Element_t &exclusive_end_arg)
Set the exclusive end to the given value.
Definition: interval.h:257
Interval(const Element_t &singleton)
Construct a singleton interval.
Definition: interval.h:210
void assert_consistent(Element_t start_arg, Element_t exclusive_end_arg)
Check that the given values are in range and in order.
Definition: interval.h:301
void throwing_assign(const Element_t &start_arg, const Element_t &exclusive_end_arg)
Set the start and exclusive end to the given values.
Definition: interval.h:239
static Interval throwing_make(const Element_t &start_arg, const Element_t &exclusive_end_arg)
Construct an interval with the given values for start and exclusive end.
Definition: interval.h:224
static Interval throwing_make(const Element_t &singleton)
Construct a singleton interval.
Definition: interval.h:232
Holds the start boundary and endpoint boundary of an interval.
Definition: interval.h:53
void set_start(Element_t start_arg)
Set the value for the start boundary, without validating the range.
Definition: interval.h:94
constexpr const Element_t & exclusive_end() const
Return const reference to the exclusive endpoint of the interval.
Definition: interval.h:110
Set_traits_tp Set_traits_t
Definition: interval.h:55
void set_exclusive_end(Element_t exclusive_end_arg)
Set the value for the exclusive_end boundary, without validating the range.
Definition: interval.h:100
constexpr Interval_base()
This is enabled if Set_traits_t are discrete set traits.
Definition: interval.h:63
constexpr const Element_t & start() const
Return const reference to the starting point of the interval (inclusive).
Definition: interval.h:107
Element_t m_values[2]
The start boundary at index 0, the exclusive end boundary at index 1.
Definition: interval.h:116
constexpr Interval_base(const Element_t &start, const Element_t &exclusive_end)
Construct an interval with the given inclusive start and exclusive end.
Definition: interval.h:68
Set_traits_t::Element_t Element_t
Definition: interval.h:56
void assign(const Element_t &start_arg, const Element_t &exclusive_end_arg)
Set both boundaries to the given values, without validating the range.
Definition: interval.h:86
constexpr Interval_base(Element_t singleton)
Construct a singleton interval.
Definition: interval.h:75
Holds the start boundary and endpoint boundary of an interval.
Definition: interval.h:140
Relaxed_interval(Args_t &&...args)
Enable all the (protected) constructors from the base class.
Definition: interval.h:149
Relaxed_interval< Set_traits_tp > This_t
Definition: interval.h:143
True if Test is a "discrete" Set traits class, i.e., it bounded, and it is possible to compute succes...
Definition: set_traits.h:119
bool operator==(const Interval_base< Set_traits_tp > &a, const Interval_base< Set_traits_tp > &b)
Return true if both start-point and end-point are equal for the intervals.
Definition: interval.h:122
Definition: gtid_set.h:183
Return_status
Simple, strongly-typed enumeration to indicate internal status: ok, error.
Definition: return_status.h:40
Define std::hash<Gtid>.
Definition: gtid.h:355