|
constexpr | unit_t ()=default |
| default constructor. More...
|
|
template<class... Args> |
constexpr | unit_t (const T value, const Args &... args) noexcept |
| constructor More...
|
|
template<class Ty , class = typename std::enable_if<traits::is_dimensionless_unit<Units>::value && std::is_arithmetic<Ty>::value>::type> |
constexpr | unit_t (const Ty value) noexcept |
| constructor More...
|
|
template<class Rep , class Period , class = std::enable_if_t<std::is_arithmetic<Rep>::value && traits::is_ratio<Period>::value>> |
constexpr | unit_t (const std::chrono::duration< Rep, Period > &value) noexcept |
| chrono constructor More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs> |
constexpr | unit_t (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) noexcept |
| copy constructor (converting) More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs> |
unit_t & | operator= (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) noexcept |
| assignment More...
|
|
template<class Ty , class = std::enable_if_t<traits::is_dimensionless_unit<Units>::value && std::is_arithmetic<Ty>::value>> |
unit_t & | operator= (const Ty &rhs) noexcept |
| assignment More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs> |
constexpr bool | operator< (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) const noexcept |
| less-than More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs> |
constexpr bool | operator<= (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) const noexcept |
| less-than or equal More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs> |
constexpr bool | operator> (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) const noexcept |
| greater-than More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs> |
constexpr bool | operator>= (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) const noexcept |
| greater-than or equal More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs, std::enable_if_t< std::is_floating_point< T >::value||std::is_floating_point< Ty >::value, int > = 0> |
constexpr bool | operator== (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) const noexcept |
| equality More...
|
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs, std::enable_if_t< std::is_integral< T >::value &&std::is_integral< Ty >::value, int > = 0> |
constexpr bool | operator== (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) const noexcept |
|
template<class UnitsRhs , typename Ty , template< typename > class NlsRhs> |
constexpr bool | operator!= (const unit_t< UnitsRhs, Ty, NlsRhs > &rhs) const noexcept |
| inequality More...
|
|
constexpr underlying_type | value () const noexcept |
| unit value More...
|
|
template<typename Ty , class = std::enable_if_t<std::is_arithmetic<Ty>::value>> |
constexpr Ty | to () const noexcept |
| unit value More...
|
|
template<typename Ty , class = std::enable_if_t<std::is_arithmetic<Ty>::value>> |
constexpr Ty | toLinearized () const noexcept |
| linearized unit value More...
|
|
template<class U > |
constexpr unit_t< U > | convert () const noexcept |
| conversion More...
|
|
template<class Ty , std::enable_if_t< traits::is_dimensionless_unit< Units >::value &&std::is_arithmetic< Ty >::value, int > = 0> |
constexpr | operator Ty () const noexcept |
| implicit type conversion. More...
|
|
template<class Ty , std::enable_if_t<!traits::is_dimensionless_unit< Units >::value &&std::is_arithmetic< Ty >::value, int > = 0> |
constexpr | operator Ty () const noexcept |
| explicit type conversion. More...
|
|
template<typename U = Units, std::enable_if_t< units::traits::is_convertible_unit< U, unit< std::ratio< 1 >, category::time_unit > >::value, int > = 0> |
constexpr | operator std::chrono::nanoseconds () const noexcept |
| chrono implicit type conversion. More...
|
|
constexpr const char * | name () const noexcept |
| returns the unit name More...
|
|
constexpr const char * | abbreviation () const noexcept |
| returns the unit abbreviation More...
|
|
constexpr | linear_scale ()=default |
| default constructor. More...
|
|
constexpr | linear_scale (const linear_scale &)=default |
|
constexpr | linear_scale (const UNIT_LIB_DEFAULT_TYPE &value, Args &&...) noexcept |
| constructor. More...
|
|
| ~linear_scale ()=default |
|
linear_scale & | operator= (const linear_scale &)=default |
|
constexpr UNIT_LIB_DEFAULT_TYPE | operator() () const noexcept |
| returns value. More...
|
|
template<class Units, typename T = UNIT_LIB_DEFAULT_TYPE, template< typename > class NonLinearScale = linear_scale>
class units::unit_t< Units, T, NonLinearScale >
Container for values which represent quantities of a given unit.
Stores a value which represents a quantity in the given units. Unit containers (except scalar values) are not convertible to built-in c++ types, in order to provide type safety in dimensional analysis. Unit containers are implicitly convertible to other compatible unit container types. Unit containers support various types of arithmetic operations, depending on their scale type.
The value of a unit_t
can only be changed on construction, or by assignment from another unit_t
type. If necessary, the underlying value can be accessed using operator()
:
meter_t m(5.0);
double val = m();
.
- Template Parameters
-
Units | unit tag for which type of units the unit_t represents (e.g. meters) |
T | underlying type of the storage. Defaults to double. |
NonLinearScale | optional scale class for the units. Defaults to linear (i.e. does not scale the unit value). Examples of non-linear scales could be logarithmic, decibel, or richter scales. Non-linear scales must adhere to the non-linear-scale concept, i.e. is_nonlinear_scale<...>::value must be true . |
- See also
-