emlabcpp
modern opinionated embedded C++ library
emlabcpp::tagged_quantity< Tag, ValueType > Class Template Reference

Class represents a quantity that uses tags to distinguish quantities instead of inheritance. More...

#include <quantity.h>

+ Inheritance diagram for emlabcpp::tagged_quantity< Tag, ValueType >:
+ Collaboration diagram for emlabcpp::tagged_quantity< Tag, ValueType >:

Public Types

using tag = Tag
 
- Public Types inherited from emlabcpp::quantity< tagged_quantity< Tag, float >, float >
using value_type = float
 

Additional Inherited Members

- Public Member Functions inherited from emlabcpp::quantity< tagged_quantity< Tag, float >, float >
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 Public Member Functions inherited from emlabcpp::quantity< tagged_quantity< Tag, float >, float >
static std::string get_unit ()
 

Detailed Description

template<typename Tag, typename ValueType = float>
class emlabcpp::tagged_quantity< Tag, ValueType >

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.

Member Typedef Documentation

◆ tag

template<typename Tag , typename ValueType = float>
using emlabcpp::tagged_quantity< Tag, ValueType >::tag = Tag

The documentation for this class was generated from the following file: