emlabcpp
modern opinionated embedded C++ library
|
Class represents a quantity that uses tags
to distinguish quantities instead of inheritance.
More...
#include <quantity.h>
Public Types | |
using | tag = Tag |
![]() | |
using | value_type = float |
Additional Inherited Members | |
![]() | |
constexpr | quantity () noexcept |
constexpr | quantity (Value val) noexcept |
Default constructor used to create a physical quantity from value. More... | |
constexpr float | operator* () const noexcept |
Const reference to the internal value. More... | |
constexpr tagged_quantity< Tag, float > & | operator+= (quantity const other) noexcept |
Add other quantity of same Derived and value_type. More... | |
constexpr tagged_quantity< Tag, float > & | operator-= (quantity const other) noexcept |
Subtract other quantity of same Derived and value_type. More... | |
constexpr tagged_quantity< Tag, float > & | operator/= (arithmetic auto const val) noexcept |
Divides quantity by it's value type. More... | |
constexpr tagged_quantity< Tag, float > & | operator*= (arithmetic auto const val) noexcept |
Multiplies quantity by it's value type. More... | |
constexpr | operator U () const noexcept |
Provides explicit conversion of internal value to type U. More... | |
![]() | |
static std::string | get_unit () |
Class represents a quantity that uses tags
to distinguish quantities instead of inheritance.
Usefull because it is simpler to write template alias such as this: using apple_count = tagget_quantity< struct apple_count_tag, uint32_t >;
Writing full class would take more effort, but class has the benefit of better error messages.
using emlabcpp::tagged_quantity< Tag, ValueType >::tag = Tag |