template<typename T = int>
recti::Interval class

Interval.

Template parameters
T

The above code is defining a template class called "Interval" with a default template parameter of type "int". The class has two private member variables: "_lb" (lower bound) and "_ub" (upper bound).

Public types

using value_type = T

Constructors, destructors, conversion operators

Interval(T&& lower, T&& upper) constexpr noexcept
Construct a new Interval object.
Interval(const T& lower, const T& upper) constexpr
Construct a new Interval object.
Interval(const T& alpha) explicit constexpr
Construct a new Interval object.

Public functions

auto operator=(const T& alpha) -> Interval & -> auto constexpr
Assignment operator.
auto lb() const -> const T & -> auto constexpr
lower bound
auto ub() const -> const T & -> auto constexpr
upper bound
auto len() const -> T -> auto constexpr
length
template<typename U>
auto overlaps(const U& other) const -> bool -> auto constexpr
Overlaps.
template<typename U>
auto contains(const U& other) const -> bool -> auto constexpr
contains
template<typename U>
auto intersection_with(const U& other) const -> auto constexpr
intersection with
template<typename U>
auto min_dist_with(const U& other) const -> T -> auto constexpr
minimum distance with
template<typename U>
auto min_dist_change_with(U& other) const -> T -> auto constexpr
minimum distance with

Comparison operators

definie ==, !=, <, >, <=, >=.

template<typename U>
auto operator==(const Interval<U>& rhs) const -> bool -> auto constexpr
Equal to.
template<typename U>
auto operator!=(const Interval<U>& rhs) const -> bool -> auto constexpr
Not equal to.
template<typename U>
auto operator<=>(const U& rhs) const -> std::weak_ordering -> auto constexpr
Spaceship operator.
auto operator<=>(const T& lhs, const Interval& rhs) -> std::weak_ordering -> auto constexpr
Spaceship operator.

Arithmetic operators

definie +, -, *, /, +=, -=, +=, /=, etc.

auto operator-() const -> Interval -> auto constexpr
Negation.
template<typename U>
auto operator+=(const U& alpha) -> Interval & -> auto constexpr
Add.
template<typename U>
auto operator-=(const U& alpha) -> Interval & -> auto constexpr
Subtract.
auto enlarge_with(const T& alpha) -> Interval & -> auto constexpr
Enlarge with.
template<typename U>
auto operator+(Interval rhs, const U& alpha) -> Interval -> auto constexpr
Add by a scalar.
auto operator+(const T& alpha, Interval rhs) -> Interval -> auto constexpr
Add (by a scalar)
template<typename U>
auto operator-(const Interval& rhs, const U& alpha) -> Interval -> auto constexpr
Subtract by a scalar.

Friends

template<class Stream>
auto operator<<(Stream& out, const Interval& intvl) -> Stream & -> auto
output stream

Function documentation

template<typename T>
recti::Interval<T>::Interval(T&& lower, T&& upper) constexpr noexcept

Construct a new Interval object.

Parameters
lower in The lower bound of the interval.
upper in The "upper" parameter is the upper bound of the interval. It represents the maximum value that can be included in the interval.

The function constructs a new Interval object with given lower and upper values.

template<typename T>
recti::Interval<T>::Interval(const T& lower, const T& upper) constexpr

Construct a new Interval object.

Parameters
lower in The lower bound of the interval. It represents the minimum value that can be included in the interval.
upper in The "upper" parameter represents the upper bound of the interval. It is the maximum value that can be included in the interval.

The function constructs a new Interval object with given lower and upper bounds.

template<typename T>
recti::Interval<T>::Interval(const T& alpha) explicit constexpr

Construct a new Interval object.

Parameters
alpha in The parameter "alpha" is of type T, which is a template parameter for the Interval class. It represents the value that will be used as both the lower bound and upper bound of the interval.

The function constructs a new Interval object with the same lower and upper bounds.

template<typename T>
auto recti::Interval<T>::operator=(const T& alpha) -> Interval & constexpr

Assignment operator.

Parameters
alpha in The parameter "alpha" is of type T, which is the type of the object being assigned to the Interval object.
Returns The assignment operator is returning a reference to the Interval object.

The assignment operator sets the lower and upper bounds of an Interval object to the given value.

template<typename T>
auto recti::Interval<T>::lb() const -> const T & constexpr

lower bound

Returns a reference to a constant object of type T.

The function returns a constant reference to the lower bound value.

template<typename T>
auto recti::Interval<T>::ub() const -> const T & constexpr

upper bound

Returns a reference to a constant object of type T.

The function returns a constant reference to the upper bound value.

template<typename T>
auto recti::Interval<T>::len() const -> T constexpr

length

Returns a value of type T.

The function returns the length of a range by subtracting the upper bound from the lower bound.

template<typename T> template<typename U>
auto recti::Interval<T>::overlaps(const U& other) const -> bool constexpr

Overlaps.

Template parameters
U
Parameters
other in
Returns true

The above code is defining a template function named "overlaps" that takes a parameter "other" of type U. The function returns a boolean value.

template<typename T> template<typename U>
auto recti::Interval<T>::contains(const U& other) const -> bool constexpr

contains

Template parameters
U
Parameters
other in
Returns true

The above code is defining a template function named "contains" that takes a parameter "other" of type U. The function returns a boolean value.

template<typename T> template<typename U>
auto recti::Interval<T>::intersection_with(const U& other) const constexpr

intersection with

Template parameters
U
Parameters
other in
Returns constexpr auto

The above code is defining a template function called intersection_with that takes a parameter other. The function returns the intersection of the current object (an Interval) with other.

template<typename T> template<typename U>
auto recti::Interval<T>::min_dist_with(const U& other) const -> T constexpr

minimum distance with

Template parameters
U
Parameters
other in
Returns constexpr auto

The above code is a C++ template function called min_dist_with. It takes a parameter other of type U and returns a value of type T.

template<typename T> template<typename U>
auto recti::Interval<T>::min_dist_change_with(U& other) const -> T constexpr

minimum distance with

Template parameters
U
Parameters
other in
Returns constexpr auto

The above code is a C++ template function called min_dist_change_with. It takes a parameter other of type U and returns a value of type T.

template<typename T> template<typename U>
auto recti::Interval<T>::operator==(const Interval<U>& rhs) const -> bool constexpr

Equal to.

Template parameters
U
Parameters
rhs in
Returns true

The above code is defining the equality operator (==) for a class template called Interval. The operator compares two Interval objects for equality by checking if their lower bounds (lb) and upper bounds (ub) are equal. If both the lower bounds and upper bounds are equal, the operator returns true, otherwise it returns false.

template<typename T> template<typename U>
auto recti::Interval<T>::operator!=(const Interval<U>& rhs) const -> bool constexpr

Not equal to.

Template parameters
U
Parameters
rhs in
Returns true

The above code is defining the "!=" (not equal to) operator for a class template called "Interval". This operator compares two Interval objects for inequality. It takes a reference to an Interval object "rhs" as a parameter and returns a boolean value. It uses the "==" (equal to) operator to determine if the two objects are equal, and then negates the result to return the opposite.

template<typename T> template<typename U>
auto recti::Interval<T>::operator<=>(const U& rhs) const -> std::weak_ordering constexpr

Spaceship operator.

Template parameters
U
Parameters
rhs in
Returns std::weak_ordering

The above code is defining a spaceship operator for a template class. The spaceship operator is a three-way comparison operator introduced in C++20. It compares the object on the left-hand side (LHS) with the object on the right-hand side (RHS) and returns a std::weak_ordering value indicating the relationship between the two objects.

template<typename T>
auto recti::Interval<T>::operator<=>(const T& lhs, const Interval& rhs) -> std::weak_ordering constexpr

Spaceship operator.

Parameters
lhs in
rhs in
Returns std::weak_ordering

The above code is defining a spaceship operator for comparing a value of type T with an Interval object. The spaceship operator (<=>) is a three-way comparison operator introduced in C++20.

template<typename T>
auto recti::Interval<T>::operator-() const -> Interval constexpr

Negation.

Returns The operator- function is returning an Interval object.

The above function returns the negation of an interval.

template<typename T> template<typename U>
auto recti::Interval<T>::operator+=(const U& alpha) -> Interval & constexpr

Add.

Parameters
alpha in
Returns Interval&

The above code is defining an operator+= function for the Interval class. This function takes a parameter alpha of type U and adds it to both the lower bound (_lb) and upper bound (_ub) of the Interval object. It then returns a reference to the modified Interval object.

template<typename T> template<typename U>
auto recti::Interval<T>::operator-=(const U& alpha) -> Interval & constexpr

Subtract.

Parameters
alpha in
Returns Interval&

The above code is defining an operator-= function for the Interval class. This function takes a parameter alpha of type U and subtracts it to both the lower bound (_lb) and upper bound (_ub) of the Interval object. It then returns a reference to the modified Interval object.

template<typename T>
auto recti::Interval<T>::enlarge_with(const T& alpha) -> Interval & constexpr

Enlarge with.

Parameters
alpha in The parameter "alpha" is of type T, which is not specified in the code snippet. It could be any data type, such as int, float, double, etc.
Returns a reference to the current object, which is an instance of the Interval class.

The enlarge_with function enlarges the interval by subtracting alpha from the lower bound and adding alpha to the upper bound.

template<typename T> template<typename U>
auto recti::Interval<T>::operator+(Interval rhs, const U& alpha) -> Interval constexpr

Add by a scalar.

Parameters
rhs in The parameter rhs represents the right-hand side of the addition operation. It is an object of type Interval.
alpha in The parameter alpha is a scalar value that will be added to the rhs interval.
Returns an Interval object.

The above code is defining a friend function named operator+ for the Interval class. This function takes an Interval object rhs and a scalar value alpha as parameters. It returns a new Interval object that is the result of adding rhs and alpha.

template<typename T>
auto recti::Interval<T>::operator+(const T& alpha, Interval rhs) -> Interval constexpr

Add (by a scalar)

Parameters
alpha in The parameter alpha is a scalar value that will be added to the rhs interval.
rhs in The parameter rhs represents the right-hand side of the addition operation. It is an object of type Interval.
Returns an Interval object.

The function adds a scalar value to an interval.

template<typename T> template<typename U>
auto recti::Interval<T>::operator-(const Interval& rhs, const U& alpha) -> Interval constexpr

Subtract by a scalar.

Parameters
rhs in The parameter rhs represents the right-hand side of the subtraction operation. It is an object of type Interval.
alpha in The parameter alpha is a scalar value that will be subtracted to the rhs interval.
Returns an Interval object.

The above code is defining a friend function named operator- for the Interval class. This function takes an Interval object rhs and a scalar value alpha as parameters. It returns a new Interval object that is the result of subtracting rhs by alpha.

template<typename T> template<class Stream>
auto operator<<(Stream& out, const Interval& intvl) -> Stream &

output stream

Template parameters
Stream
Parameters
out out
intvl in
Returns Stream&

The above code is defining a friend function for the Interval class in C++. This friend function is an output stream operator overload (<<) that takes a reference to a Stream object (out) and a const reference to an Interval object (intvl).