bn::fixed_size class

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

Constructors, destructors, conversion operators

fixed_size() defaulted constexpr
Default constructor.
fixed_size(fixed width, fixed height) constexpr
Constructor.
fixed_size(const size& size) constexpr
Constructor.

Public functions

auto width() const -> fixed constexpr
Returns the width.
void set_width(fixed width) constexpr
Sets the width.
auto height() const -> fixed constexpr
Returns the height.
void set_height(fixed height) constexpr
Sets the height.
auto multiplication(int value) const -> fixed_size constexpr
Returns the multiplication of this size by the given integer value.
auto multiplication(fixed value) const -> fixed_size 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 constexpr
Returns the multiplication of this size by the given integer value.
auto safe_multiplication(fixed value) const -> fixed_size 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 constexpr
Returns the multiplication of this size by the given integer value.
auto unsafe_multiplication(fixed value) const -> fixed_size 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 constexpr
Returns the division of this size by the given integer value.
auto division(fixed value) const -> fixed_size 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 constexpr
Returns the division of this value by the given integer value.
auto safe_division(fixed value) const -> fixed_size 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 constexpr
Returns the division of this value by the given integer value.
auto unsafe_division(fixed value) const -> fixed_size constexpr
Returns the division of this size by the given fixed point value without trying to avoid overflow.
auto operator+=(const fixed_size& other) -> fixed_size& constexpr
Adds the given fixed_size to this one.
auto operator-=(const fixed_size& other) -> fixed_size& constexpr
Subtracts the given fixed_size to this one.
auto operator*=(int value) -> fixed_size& constexpr
Multiplies both width and height by the given factor.
auto operator*=(fixed value) -> fixed_size& constexpr
Multiplies both width and height by the given factor.
auto operator/=(int value) -> fixed_size& constexpr
Divides both width and height by the given divisor.
auto operator/=(fixed value) -> fixed_size& constexpr
Divides both width and height by the given divisor.

Friends

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

Function documentation

bn::fixed_size::fixed_size(fixed width, fixed height) constexpr

Constructor.

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

bn::fixed_size::fixed_size(const size& size) constexpr

Constructor.

Parameters
size Integer size.

void bn::fixed_size::set_width(fixed width) constexpr

Sets the width.

Parameters
width Valid width (>= 0).

void bn::fixed_size::set_height(fixed height) constexpr

Sets the height.

Parameters
height Valid height (>= 0).

fixed_size& bn::fixed_size::operator+=(const fixed_size& other) constexpr

Adds the given fixed_size to this one.

Parameters
other fixed_size to add.
Returns Reference to this.

fixed_size& bn::fixed_size::operator-=(const fixed_size& other) constexpr

Subtracts the given fixed_size to this one.

Parameters
other fixed_size to subtract.
Returns Reference to this.

fixed_size& bn::fixed_size::operator*=(int value) constexpr

Multiplies both width and height by the given factor.

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

fixed_size& bn::fixed_size::operator*=(fixed value) constexpr

Multiplies both width and height by the given factor.

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

fixed_size& bn::fixed_size::operator/=(int value) constexpr

Divides both width and height by the given divisor.

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

fixed_size& bn::fixed_size::operator/=(fixed value) constexpr

Divides both width and height by the given divisor.

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