template <typename T, typename = std::enable_if_t<is_num_v<T>>>
rll::velocity struct

Newtype describing a velocity.

Template parameters
T Number type. Must satisfy concept rll::concepts::num. Default is f32.

Public types

using number_type = T
Underlying number type.

Public static functions

static auto from(number_type value, velocity_unit u) →  velocity constexpr
Constructs an velocity from another unit.
static auto from_kmph(number_type kmph) →  velocity constexpr
Constructs an velocity from kilometers-per-hour value.
static auto from_mps(number_type mps) →  velocity constexpr
Constructs an velocity from meters-per-second value.
static auto zero() →  velocity constexpr
Constructs an zero velocity.

Constructors, destructors, conversion operators

operator bool() const explicit constexpr
Returns true if underlying value is not 0.
operator number_type() const explicit constexpr
Returns the underlying value as number_type.
velocity() constexpr
Constructs an zero velocity.
velocity(number_type const value) explicit constexpr
Constructs an velocity from a numeric value.
velocity(velocity const&) defaulted constexpr
Copy constructor.
velocity(velocity&&) defaulted constexpr
Move constructor.
~velocity() defaulted
Default destructor.

Public functions

template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto as() const →  U constexpr
Returns this numeric newtype as number in another numeric representation.
auto as_f32() const →  f32 constexpr
Returns this velocity as 32-bit floating-point number.
auto as_f64() const →  f64 constexpr
Returns this velocity as 64-bit floating-point number.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto cast() const →  velocity<U> constexpr
Casts the velocity to another numeric type.
auto in(velocity_unit u) const →  number_type constexpr
Returns the velocity in the given unit.
auto is_finite() const →  bool
Returns true if this velocity is a finite number.
auto kmph() const →  number_type constexpr
Returns the velocity in kilometers per hour.
auto mps() const →  number_type constexpr
Returns the velocity in meters per second.
auto operator!=(velocity const& other) const →  bool constexpr
Compares this and other velocity with rll::math::approx_eq for inequality.
auto operator*() const →  number_type constexpr
Returns the underlying numeric scalar.
auto operator*(velocity const& other) const →  velocity constexpr
Returns this * other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator*(U const& other) const →  velocity constexpr
Returns this * other.
auto operator*=(velocity const& other) →  velocity& constexpr
Returns this *= other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator*=(U const& other) →  velocity& constexpr
Returns this *= other.
auto operator+() const →  velocity constexpr
Returns this.
auto operator+(velocity const& other) const →  velocity constexpr
Returns this + other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator+(U const& other) const →  velocity constexpr
Returns this + other.
auto operator++() →  T& constexpr
Increments the underlying value by 1.
auto operator++(int) →  T& constexpr
Increments the underlying value by 1.
auto operator+=(velocity const& other) →  velocity& constexpr
Returns this += other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator+=(U const& other) →  velocity& constexpr
Returns this += other.
auto operator-() const →  velocity constexpr
Returns -this.
auto operator-(velocity const& other) const →  velocity constexpr
Returns this - other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator-(U const& other) const →  velocity constexpr
Returns this - other.
auto operator--() →  T& constexpr
Decrements the underlying value by 1.
auto operator--(int) →  T& constexpr
Decrements the underlying value by 1.
auto operator-=(velocity const& other) →  velocity& constexpr
Returns this -= other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator-=(U const& other) →  velocity& constexpr
Returns this -= other.
auto operator/(velocity const& other) const →  velocity constexpr
Returns this / other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator/(U const& other) const →  velocity constexpr
Returns this / other.
auto operator/=(velocity const& other) →  velocity& constexpr
Returns this /= other.
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
auto operator/=(U const& other) →  velocity& constexpr
Returns this /= other.
auto operator<(velocity const& other) const →  bool constexpr
Compares this and other velocity for less than.
auto operator<=(velocity const& other) const →  bool constexpr
Compares this and other velocity for less than or equal to.
auto operator=(velocity const&) →  velocity& defaulted constexpr
Copy assignment.
auto operator=(velocity&&) →  velocity& defaulted constexpr
Move assignment.
auto operator==(velocity const& other) const →  bool constexpr
Compares this and other velocity with rll::math::approx_eq for equality.
auto operator>(velocity const& other) const →  bool constexpr
Compares this and other velocity for greater than.
auto operator>=(velocity const& other) const →  bool constexpr
Compares this and other velocity for greater than or equal to.
auto to_string(velocity_unit u = velocity_unit::meters_per_second) const →  std::string
Returns string representation of the velocity.
auto value() const →  number_type constexpr
Returns the underlying numeric scalar value.

Friends

auto operator<<(std::ostream& os, velocity const& a) →  std::ostream&

Function documentation

template <typename T, typename _2>
static velocity rll::velocity::from(number_type value, velocity_unit u) constexpr

Constructs an velocity from another unit.

Parameters
value Numeric value.
u Unit.
Returns Constructed velocity.

template <typename T, typename _2>
static velocity rll::velocity::from_kmph(number_type kmph) constexpr

Constructs an velocity from kilometers-per-hour value.

Parameters
kmph Velocity in kilometers-per-hour.
Returns Constructed velocity.

template <typename T, typename _2>
static velocity rll::velocity::from_mps(number_type mps) constexpr

Constructs an velocity from meters-per-second value.

Parameters
mps Velocity in meters-per-second.
Returns Constructed velocity.

template <typename T, typename _2>
rll::velocity::velocity() constexpr

Constructs an zero velocity.

template <typename T, typename _2>
rll::velocity::velocity(number_type const value) explicit constexpr

Constructs an velocity from a numeric value.

Parameters
value Numeric value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
U rll::velocity::as() const constexpr

Returns this numeric newtype as number in another numeric representation.

Template parameters
U Number type. Must satisfy concept rll::concepts::num.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity<U> rll::velocity::cast() const constexpr

Casts the velocity to another numeric type.

Template parameters
U Target numeric type.
Returns Cast velocity.

template <typename T, typename _2>
number_type rll::velocity::in(velocity_unit u) const constexpr

Returns the velocity in the given unit.

Parameters
u Unit to return the velocity in.
Returns Velocity in the given unit.

template <typename T, typename _2>
number_type rll::velocity::kmph() const constexpr

Returns the velocity in kilometers per hour.

template <typename T, typename _2>
number_type rll::velocity::mps() const constexpr

Returns the velocity in meters per second.

template <typename T, typename _2>
bool rll::velocity::operator!=(velocity const& other) const constexpr

Compares this and other velocity with rll::math::approx_eq for inequality.

Parameters
other Other velocity.
Returns true if both velocities are not approximately equal, false otherwise.

template <typename T, typename _2>
number_type rll::velocity::operator*() const constexpr

Returns the underlying numeric scalar.

Returns The underlying numeric scalar.

template <typename T, typename _2>
velocity rll::velocity::operator*(velocity const& other) const constexpr

Returns this * other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity rll::velocity::operator*(U const& other) const constexpr

Returns this * other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
velocity& rll::velocity::operator*=(velocity const& other) constexpr

Returns this *= other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity& rll::velocity::operator*=(U const& other) constexpr

Returns this *= other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
velocity rll::velocity::operator+(velocity const& other) const constexpr

Returns this + other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity rll::velocity::operator+(U const& other) const constexpr

Returns this + other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
velocity& rll::velocity::operator+=(velocity const& other) constexpr

Returns this += other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity& rll::velocity::operator+=(U const& other) constexpr

Returns this += other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
velocity rll::velocity::operator-(velocity const& other) const constexpr

Returns this - other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity rll::velocity::operator-(U const& other) const constexpr

Returns this - other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
velocity& rll::velocity::operator-=(velocity const& other) constexpr

Returns this -= other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity& rll::velocity::operator-=(U const& other) constexpr

Returns this -= other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
velocity rll::velocity::operator/(velocity const& other) const constexpr

Returns this / other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity rll::velocity::operator/(U const& other) const constexpr

Returns this / other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
velocity& rll::velocity::operator/=(velocity const& other) constexpr

Returns this /= other.

Parameters
other The other value.

template <typename T, typename _2>
template <typename U, typename = std::enable_if_t<is_num_v<T>>>
velocity& rll::velocity::operator/=(U const& other) constexpr

Returns this /= other.

Template parameters
U Right hand side numeric type.
Parameters
other The other value.

template <typename T, typename _2>
bool rll::velocity::operator<(velocity const& other) const constexpr

Compares this and other velocity for less than.

Parameters
other Other velocity.
Returns true if this velocities is less than other, false otherwise.

template <typename T, typename _2>
bool rll::velocity::operator<=(velocity const& other) const constexpr

Compares this and other velocity for less than or equal to.

Parameters
other Other velocity.
Returns true if this velocities is less than or equal to other, false otherwise.

template <typename T, typename _2>
bool rll::velocity::operator==(velocity const& other) const constexpr

Compares this and other velocity with rll::math::approx_eq for equality.

Parameters
other Other velocity.
Returns true if both velocities are approximately equal, false otherwise.

template <typename T, typename _2>
bool rll::velocity::operator>(velocity const& other) const constexpr

Compares this and other velocity for greater than.

Parameters
other Other velocity.
Returns true if this velocities is greater than other, false otherwise.

template <typename T, typename _2>
bool rll::velocity::operator>=(velocity const& other) const constexpr

Compares this and other velocity for greater than or equal to.

Parameters
other Other velocity.
Returns true if this velocities is greater than or equal to other, false otherwise.

template <typename T, typename _2>
std::string rll::velocity::to_string(velocity_unit u = velocity_unit::meters_per_second) const

Returns string representation of the velocity.

Parameters
u Representation measurement unit. Default is meters per second.
Returns String representation of the object.

Velocity is represented in specified unit. If the underlying number type is floating point, it is rounded to two decimal places.

template <typename T, typename _2>
number_type rll::velocity::value() const constexpr

Returns the underlying numeric scalar value.

Returns The underlying numeric scalar value.