C++ Essence Library 0.1.0
A Utility Library for Modern C++ Programming
Loading...
Searching...
No Matches
essence::rect< Number > Struct Template Reference

Illustrates a rectangle. More...

#include <rect.hpp>

Public Member Functions

constexpr auto operator<=> (const rect &) const noexcept=default
 
constexpr Number right () const noexcept
 
constexpr Number bottom () const noexcept
 
constexpr Number area () const noexcept
 
template<typename T >
requires bottom_right_rect<std::decay_t<T>>
constexpr operator T () const noexcept(nothrow_bottom_right_rect< std::decay_t< T > >)
 Converts to a compatible rectangle that contains member variables left, top, right, bottom.
 
template<typename T >
requires equivalent_rect<std::decay_t<T>>
constexpr operator T () const noexcept(nothrow_equivalent_rect< std::decay_t< T > >)
 Converts to an equivalent rectangle that contains member variables x, y, width, height.
 
template<width_height_pair T>
constexpr T to_extent () const noexcept(nothrow_width_height_pair< T >)
 Retrieves the width-height pair.
 
template<width_height_pair T>
constexpr void assign_from_extent (const T &pair) noexcept
 Sets the width and height from a width-height pair.
 
constexpr bool collapsed () const noexcept
 Checks whether the area of the rectangle is zero (i.e. collapsed to a zero-dimensional point).
 

Static Public Member Functions

template<bottom_right_rect T>
static constexpr rect from (const T &bottom_right_rect) noexcept
 Makes a rectangle from a compatible rectangle that contains member variables x, y, width, height.
 
template<equivalent_rect T>
static constexpr rect from (const T &equivalent_rect) noexcept
 Makes a rectangle from an equivalent rectangle that contains member variables x, y, bottom, right.
 

Public Attributes

Number x {}
 
Number y {}
 
Number width {}
 
Number height {}
 

Detailed Description

template<typename Number>
requires std::is_arithmetic_v<Number>
struct essence::rect< Number >

Illustrates a rectangle.

Template Parameters
NumberThe numeric type of the member variables.

Member Function Documentation

◆ assign_from_extent()

template<typename Number >
template<width_height_pair T>
void essence::rect< Number >::assign_from_extent ( const T & pair)
inlineconstexprnoexcept

Sets the width and height from a width-height pair.

Template Parameters
TThe type of the pair that contains member variables width and height.
Parameters
pairThe weight-height pair.

◆ collapsed()

template<typename Number >
bool essence::rect< Number >::collapsed ( ) const
inlinenodiscardconstexprnoexcept

Checks whether the area of the rectangle is zero (i.e. collapsed to a zero-dimensional point).

Returns
True if the area is zero; otherwise false.

◆ from() [1/2]

template<typename Number >
template<bottom_right_rect T>
static constexpr rect essence::rect< Number >::from ( const T & bottom_right_rect)
inlinestaticconstexprnoexcept

Makes a rectangle from a compatible rectangle that contains member variables x, y, width, height.

Template Parameters
TThe type of the compatible rectangle.
Parameters
bottom_right_rectThe compatible rectangle.
Returns
The rectangle.

◆ from() [2/2]

template<typename Number >
template<equivalent_rect T>
static constexpr rect essence::rect< Number >::from ( const T & equivalent_rect)
inlinestaticconstexprnoexcept

Makes a rectangle from an equivalent rectangle that contains member variables x, y, bottom, right.

Template Parameters
TThe type of the equivalent rectangle.
Parameters
equivalent_rectThe equivalent rectangle。
Returns
The rectangle.

◆ operator T() [1/2]

template<typename Number >
template<typename T >
requires bottom_right_rect<std::decay_t<T>>
essence::rect< Number >::operator T ( ) const
inlineconstexprnoexcept

Converts to a compatible rectangle that contains member variables left, top, right, bottom.

Template Parameters
TThe type of the compatible rectangle.

◆ operator T() [2/2]

template<typename Number >
template<typename T >
requires equivalent_rect<std::decay_t<T>>
essence::rect< Number >::operator T ( ) const
inlineconstexprnoexcept

Converts to an equivalent rectangle that contains member variables x, y, width, height.

Template Parameters
TThe type of the equivalent rectangle.

◆ to_extent()

template<typename Number >
template<width_height_pair T>
T essence::rect< Number >::to_extent ( ) const
inlineconstexprnoexcept

Retrieves the width-height pair.

Template Parameters
TThe type of the pair that contains member variables width and height.
Returns
The weight-height pair.

The documentation for this struct was generated from the following file: