9#ifdef TYPE_SI_DISABLE_CHECKS
27 explicit Unit(
const T &value = T()) : _value(value) {}
30 template <
typename AnotherT>
32 : _value(static_cast<AnotherT>(unit)) {}
35 template <
typename AnotherT>
explicit operator AnotherT()
const {
36 return static_cast<AnotherT
>(_value);
41 template <
typename AnotherT>
42 decltype(std::declval<T>() == std::declval<AnotherT>())
44 return _value ==
static_cast<AnotherT
>(unit);
47 template <
typename AnotherT>
48 decltype(std::declval<T>() != std::declval<AnotherT>())
50 return _value !=
static_cast<AnotherT
>(unit);
53 template <
typename AnotherT>
54 decltype(std::declval<T>() < std::declval<AnotherT>())
56 return _value < static_cast<AnotherT>(unit);
59 template <
typename AnotherT>
60 decltype(std::declval<T>() <= std::declval<AnotherT>())
62 return _value <= static_cast<AnotherT>(unit);
65 template <
typename AnotherT>
66 decltype(std::declval<T>() > std::declval<AnotherT>())
68 return _value >
static_cast<AnotherT
>(unit);
71 template <
typename AnotherT>
72 decltype(std::declval<T>() >= std::declval<AnotherT>())
74 return _value >=
static_cast<AnotherT
>(unit);
77 template <
typename AnotherT>
81 Powers...>(_value +
static_cast<AnotherT
>(unit));
91 template <
typename AnotherT>
93 _value +=
static_cast<AnotherT
>(unit);
97 template <
typename AnotherT>
101 Powers...>(_value -
static_cast<AnotherT
>(unit));
104 template <
typename AnotherT>
106 _value -=
static_cast<AnotherT
>(unit);
118 operator*(
const T &value)
const {
124 operator/(
const T &value)
const {
139 template <
typename AnotherT,
typename... OtherPowers>
141 std::ratio_add<Powers, OtherPowers>...>
144 std::ratio_add<Powers, OtherPowers>...>(
145 _value *
static_cast<AnotherT
>(unit));
148 template <
typename AnotherT,
typename... OtherPowers>
150 std::ratio_subtract<Powers, OtherPowers>...>
153 std::ratio_subtract<Powers, OtherPowers>...>(
154 _value /
static_cast<AnotherT
>(unit));
159template <
typename... Elements>
struct Tuple {};
161template <
typename T,
typename...
Powers>
173 std::ratio<0>, std::ratio<0>, std::ratio<0>>;
Generic unit type.
Definition: si_internal.hpp:22
Unit & operator/=(const T &value)
Operator '/=' for dimensionless operand of container type.
Definition: si_internal.hpp:134
Unit operator--(int)
Postfix decrement.
Definition: si_internal.hpp:115
Unit & operator-=(const Unit< AnotherT, Powers... > &unit)
Operator '-=' for units with same power values.
Definition: si_internal.hpp:105
T operator+() const
Conversion to container type via unary '+'.
Definition: si_internal.hpp:39
Unit(const Unit< AnotherT, Powers... > &unit)
Implicit constructor from units with same power values but different container type.
Definition: si_internal.hpp:31
Unit operator++(int)
Postfix increment.
Definition: si_internal.hpp:89
Unit & operator*=(const T &value)
Operator '*=' for dimensionless operand of container type.
Definition: si_internal.hpp:129
Unit(const T &value=T())
Explicit constructor from container type.
Definition: si_internal.hpp:27
Unit & operator--()
Prefix decrement.
Definition: si_internal.hpp:110
Unit & operator++()
Prefix increment.
Definition: si_internal.hpp:84
Unit & operator+=(const Unit< AnotherT, Powers... > &unit)
Operator '+=' for units with same power values.
Definition: si_internal.hpp:92
decltype(getPowers(std::declval< U >())) Powers
Tool to get tuple of powers from unit.
Definition: si_internal.hpp:165
Tuple< Powers... > getPowers(Unit< T, Powers... >)
Helper to get tuple of powers from unit.
Definition: si_internal.hpp:162
Metastructure to identify and compare typename sets.
Definition: si_internal.hpp:159