template<int Precision>
bn::fixed_size_t class

Defines the size of a two-dimensional object using fixed point precision.

Constructors, destructors, conversion operators

fixed_size_t() defaulted constexpr
Default constructor.
fixed_size_t(fixed_t<Precision> width, fixed_t<Precision> height) constexpr
Constructor.
fixed_size_t(const size& size) constexpr
Constructor.

Public functions

auto width() const -> fixed_t<Precision> constexpr
Returns the width.
void set_width(fixed_t<Precision> width) constexpr
Sets the width.
auto height() const -> fixed_t<Precision> constexpr
Returns the height.
void set_height(fixed_t<Precision> height) constexpr
Sets the height.
auto multiplication(int value) const -> fixed_size_t constexpr
Returns the multiplication of this size by the given integer value.
auto multiplication(fixed_t<Precision> value) const -> fixed_size_t constexpr
Returns the multiplication of this size by the given fixed point value, using half precision to try to avoid overflow.
auto safe_multiplication(int value) const -> fixed_size_t constexpr
Returns the multiplication of this size by the given integer value.
auto safe_multiplication(fixed_t<Precision> value) const -> fixed_size_t constexpr
Returns the multiplication of this size by the given fixed point value, casting them to int64_t to try to avoid overflow.
auto unsafe_multiplication(int value) const -> fixed_size_t constexpr
Returns the multiplication of this size by the given integer value.
auto unsafe_multiplication(fixed_t<Precision> value) const -> fixed_size_t constexpr
Returns the multiplication of this size by the given fixed point value without trying to avoid overflow.
auto division(int value) const -> fixed_size_t constexpr
Returns the division of this size by the given integer value.
auto division(fixed_t<Precision> value) const -> fixed_size_t constexpr
Returns the division of this size by the given fixed point value, using half precision to try to avoid overflow.
auto safe_division(int value) const -> fixed_size_t constexpr
Returns the division of this value by the given integer value.
auto safe_division(fixed_t<Precision> value) const -> fixed_size_t constexpr
Returns the division of this size by the given fixed point value, casting them to int64_t to try to avoid overflow.
auto unsafe_division(int value) const -> fixed_size_t constexpr
Returns the division of this value by the given integer value.
auto unsafe_division(fixed_t<Precision> value) const -> fixed_size_t constexpr
Returns the division of this size by the given fixed point value without trying to avoid overflow.
auto operator+=(const fixed_size_t& other) -> fixed_size_t& constexpr
Adds the given fixed_size_t to this one.
auto operator-=(const fixed_size_t& other) -> fixed_size_t& constexpr
Subtracts the given fixed_size_t to this one.
auto operator*=(int value) -> fixed_size_t& constexpr
Multiplies both width and height by the given factor.
auto operator*=(fixed_t<Precision> value) -> fixed_size_t& constexpr
Multiplies both width and height by the given factor.
auto operator/=(int value) -> fixed_size_t& constexpr
Divides both width and height by the given divisor.
auto operator/=(fixed_t<Precision> value) -> fixed_size_t& constexpr
Divides both width and height by the given divisor.

Friends

auto operator+(const fixed_size_t& a, const fixed_size_t& b) -> fixed_size_t constexpr
Returns the sum of a and b.
auto operator-(const fixed_size_t& a, const fixed_size_t& b) -> fixed_size_t constexpr
Returns b subtracted from a.
auto operator*(const fixed_size_t& a, int b) -> fixed_size_t constexpr
Returns a multiplied by b.
auto operator*(const fixed_size_t& a, fixed_t<Precision> b) -> fixed_size_t constexpr
Returns a multiplied by b.
auto operator/(const fixed_size_t& a, int b) -> fixed_size_t constexpr
Returns a divided by b.
auto operator/(const fixed_size_t& a, fixed_t<Precision> b) -> fixed_size_t constexpr
Returns a divided by b.
auto operator==(const fixed_size_t& a, const fixed_size_t& b) -> bool defaulted constexpr
Default equal operator.

Function documentation

template<int Precision>
bn::fixed_size_t<Precision>::fixed_size_t(fixed_t<Precision> width, fixed_t<Precision> height) constexpr

Constructor.

Parameters
width Valid width (>= 0).
height Valid height (>= 0).

template<int Precision>
bn::fixed_size_t<Precision>::fixed_size_t(const size& size) constexpr

Constructor.

Parameters
size Integer size.

template<int Precision>
void bn::fixed_size_t<Precision>::set_width(fixed_t<Precision> width) constexpr

Sets the width.

Parameters
width Valid width (>= 0).

template<int Precision>
void bn::fixed_size_t<Precision>::set_height(fixed_t<Precision> height) constexpr

Sets the height.

Parameters
height Valid height (>= 0).

template<int Precision>
fixed_size_t& bn::fixed_size_t<Precision>::operator+=(const fixed_size_t& other) constexpr

Adds the given fixed_size_t to this one.

Parameters
other fixed_size_t to add.
Returns Reference to this.

template<int Precision>
fixed_size_t& bn::fixed_size_t<Precision>::operator-=(const fixed_size_t& other) constexpr

Subtracts the given fixed_size_t to this one.

Parameters
other fixed_size_t to subtract.
Returns Reference to this.

template<int Precision>
fixed_size_t& bn::fixed_size_t<Precision>::operator*=(int value) constexpr

Multiplies both width and height by the given factor.

Parameters
value Valid integer multiplication factor (>= 0).
Returns Reference to this.

template<int Precision>
fixed_size_t& bn::fixed_size_t<Precision>::operator*=(fixed_t<Precision> value) constexpr

Multiplies both width and height by the given factor.

Parameters
value Valid fixed point multiplication factor (>= 0).
Returns Reference to this.

template<int Precision>
fixed_size_t& bn::fixed_size_t<Precision>::operator/=(int value) constexpr

Divides both width and height by the given divisor.

Parameters
value Valid integer divisor (> 0).
Returns Reference to this.

template<int Precision>
fixed_size_t& bn::fixed_size_t<Precision>::operator/=(fixed_t<Precision> value) constexpr

Divides both width and height by the given divisor.

Parameters
value Valid fixed point divisor (> 0).
Returns Reference to this.