bn::size class
#include <bn_size.h>

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

Constructors, destructors, conversion operators

size() defaulted constexpr
Default constructor.
size(int width, int height) constexpr
Constructor.

Public functions

auto width() const -> int constexpr
Returns the width.
void set_width(int width) constexpr
Sets the width.
auto height() const -> int constexpr
Returns the height.
void set_height(int height) constexpr
Sets the height.
auto operator+=(const size& other) -> size& constexpr
Adds the given size to this one.
auto operator-=(const size& other) -> size& constexpr
Subtracts the given size to this one.
auto operator*=(int value) -> size& constexpr
Multiplies both width and height by the given factor.
auto operator/=(int value) -> size& constexpr
Divides both width and height by the given divisor.

Friends

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

Function documentation

bn::size::size(int width, int height) constexpr

Constructor.

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

void bn::size::set_width(int width) constexpr

Sets the width.

Parameters
width Valid width (>= 0).

void bn::size::set_height(int height) constexpr

Sets the height.

Parameters
height Valid height (>= 0).

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

Adds the given size to this one.

Parameters
other size to add.
Returns Reference to this.

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

Subtracts the given size to this one.

Parameters
other size to subtract.
Returns Reference to this.

size& bn::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.

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

Divides both width and height by the given divisor.

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