base template class for holding values of type _type to be multiplied with a ratio _ratio
More...
|
constexpr | unit_t (_type v) |
| Construct with value v. More...
|
|
constexpr | unit_t ()=default |
|
constexpr | unit_t (const unit_t &)=default |
|
constexpr | unit_t (unit_t &&)=default |
|
template<typename _type_rhs > |
constexpr | unit_t (const unit_t< _symbol, _exponent, _type_rhs, _ratio > &rhs) |
| construct from other unit with implicitly convertible type More...
|
|
| ~unit_t ()=default |
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr | unit_t (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) |
|
template<typename _rhs_ratio > |
constexpr | unit_t (unit_t< _symbol, _exponent, _type, _rhs_ratio > &&rhs) |
|
constexpr _type | value () const |
| returns the stored value as raw type More...
|
|
template<typename _unit_rhs > |
constexpr _unit_rhs | as () const |
|
template<template< typename _type_rhs > typename _unit_rhs> |
constexpr _unit_rhs< _type > | as () const |
|
void | setValue (_type v) |
|
constexpr unit_t & | operator= (const unit_t &rhs)=default |
| Assignment for same ratio. More...
|
|
constexpr unit_t & | operator= (unit_t &&rhs)=default |
| Move assignment for same ratio. More...
|
|
template<typename _rhs_ratio , std::enable_if_t<!std::ratio_equal_v< _rhs_ratio, _ratio >> * = nullptr> |
constexpr unit_t & | operator= (const unit_t< _symbol, _exponent, _type, _rhs_ratio > &rhs) |
| Assignment of same unit but different ratio. More...
|
|
template<typename _rhs_ratio , std::enable_if_t<!std::ratio_equal_v< _rhs_ratio, _ratio >> * = nullptr> |
constexpr unit_t & | operator= (unit_t< _symbol, _exponent, _type, _rhs_ratio > &&rhs) |
| Move assignment of same unit but different ratio. More...
|
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr bool | operator== (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr bool | operator!= (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
| compares two values, considers different ratios. More...
|
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr bool | operator< (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr bool | operator<= (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr bool | operator> (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr bool | operator>= (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
constexpr unit_t | operator* (const _type f) const |
| multiply with a non-unit scalar More...
|
|
template<typename _rhs_exponent , typename _rhs_type > |
constexpr auto | operator* (const unit_t< _symbol, _rhs_exponent, _rhs_type, _ratio > &rhs) const |
| multiply with an unit of the same ratio More...
|
|
template<typename _rhs_exponent , typename _rhs_ratio , typename _rhs_type > |
constexpr auto | operator* (const unit_t< _symbol, _rhs_exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
constexpr unit_t & | operator*= (const _type scalar) |
| multiply with a non-unit scalar More...
|
|
constexpr unit_t | operator/ (const _type f) const |
| divide by a non-unit scalar More...
|
|
template<typename _rhs_exponent , typename _rhs_type , std::enable_if_t< std::ratio_not_equal_v< _rhs_exponent, _exponent >> * = nullptr> |
constexpr auto | operator/ (const unit_t< _symbol, _rhs_exponent, _rhs_type, _ratio > &rhs) const |
|
template<typename _rhs_exponent , typename _rhs_type , typename _rhs_ratio , std::enable_if_t< std::ratio_not_equal_v< _rhs_exponent, _exponent >> * = nullptr> |
constexpr auto | operator/ (const unit_t< _symbol, _rhs_exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
template<typename _rhs_type > |
constexpr _type | operator/ (const unit_t< _symbol, _exponent, _rhs_type, _ratio > &rhs) |
| divide whit same unit result is a scalar More...
|
|
template<typename _rhs_exponent , typename _rhs_type , typename _rhs_ratio , std::enable_if_t< std::ratio_equal_v< _rhs_exponent, exponent >> * = nullptr> |
constexpr _type | operator/ (const unit_t< _symbol, _rhs_exponent, _rhs_type, _rhs_ratio > &rhs) const |
|
constexpr unit_t & | operator/= (const _type scalar) |
| divide with a non-unit scalar More...
|
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr unit_t | operator+ (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
| adds two values, returning type is type of lhs More...
|
|
constexpr unit_t & | operator+= (const unit_t &rhs) |
| add-assign value of the same unit More...
|
|
template<typename _rhs_type , typename _rhs_ratio , std::enable_if_t<!std::ratio_equal_v< _rhs_ratio, _ratio >> * = nullptr> |
constexpr unit_t & | operator+= (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) |
| add value of the same type but possibly different ratio More...
|
|
template<typename _rhs_type , typename _rhs_ratio > |
constexpr unit_t | operator- (const unit_t< _symbol, _exponent, _rhs_type, _rhs_ratio > &rhs) const |
| subtracts two values, returning type is type of lhs More...
|
|
constexpr unit_t & | operator-= (const unit_t &rhs) |
| Subtract-assign value of the same unit. More...
|
|
template<typename _rhs_type , typename _rhs_ratio , std::enable_if<!std::ratio_equal_v< _rhs_ratio, _ratio >> * = nullptr> |
constexpr unit_t & | operator-= (const unit_t< _symbol, _exponent, _type, _rhs_ratio > &rhs) |
| subtract value of the same type but possibly different ratio More...
|
|
constexpr unit_t | operator- () const |
| negate operation More...
|
|
unit_t & | operator++ () |
| increment by prefix ++ More...
|
|
unit_t | operator++ (int) |
| increment by postfix ++ More...
|
|
unit_t & | operator-- () |
| decrement by prefix – More...
|
|
unit_t | operator-- (int) |
| decrement by postfix – More...
|
|
template<char _symbol, typename _exponent, typename _type, typename _ratio = std::ratio<1>>
struct SI::detail::unit_t< _symbol, _exponent, _type, _ratio >
base template class for holding values of type _type to be multiplied with a ratio _ratio
- Todo:
add in-place unit_cast for move operators
add logarithmic units (decibel)
add constants for speed of light, planck constant, elementary charge, boltzmann constant, avogadro constant and luminous efficacy of monochromatic radiation of frequency
- Template Parameters
-
_symbol | dimension symbol of the unit (see https://en.wikipedia.org/wiki/SI_base_unit) |
_ratio | Ratio in relation to the base unit of a SI unit |
_type | internal representation of the value |
_exponent | the exponent to the unit (i.e. length == m^1, area == m^2, volume = m^3) |