|
electro 0.3.0
Type-safe electrical units library modeled after std::chrono
|
A quantity of an electrical unit with a representation and precision. More...
#include <electro/electro.hpp>
Public Types | |
| using | unit = Unit |
| The unit tag type. | |
| using | rep = Rep |
| The representation type. | |
| using | precision = typename Precision::type |
| The precision as a std::ratio. | |
Static Public Member Functions | |
| static constexpr quantity | zero () noexcept |
| Returns a zero quantity. | |
| static constexpr quantity | min () noexcept |
| Returns the minimum representable quantity. | |
| static constexpr quantity | max () noexcept |
| Returns the maximum representable quantity. | |
A quantity of an electrical unit with a representation and precision.
Similar to std::chrono::duration, quantity represents an amount of some electrical unit (volts, amperes, ohms, ...). The precision is expressed as a std::ratio of one base unit.
| Unit | The unit tag type (volt_unit, ampere_unit, ...). |
| Rep | Arithmetic type for the tick count. |
| Precision | A std::ratio representing the precision (default: 1). |
Definition at line 286 of file electro.hpp.
The precision as a std::ratio.
Definition at line 297 of file electro.hpp.
The representation type.
Definition at line 295 of file electro.hpp.
The unit tag type.
Definition at line 293 of file electro.hpp.
|
constexprdefault |
Constructs a zero quantity.
Referenced by electro::quantity< Unit, Rep, Precision >::max(), electro::quantity< Unit, Rep, Precision >::min(), electro::quantity< Unit, Rep, Precision >::operator++(), electro::quantity< Unit, Rep, Precision >::operator--(), and electro::quantity< Unit, Rep, Precision >::zero().
|
default |
|
inlineexplicitconstexpr |
Constructs from a tick count.
Implicit for inexact types, explicit otherwise to prevent accidental precision loss.
| Rep2 | The source representation type. |
| r | The tick count. |
Definition at line 314 of file electro.hpp.
|
inlineconstexpr |
Constructs from another quantity of the same unit with different representation or precision.
Implicit when the conversion is lossless (target precision evenly divides source precision).
| Rep2 | Source representation type. |
| Precision2 | Source precision. |
| q | The source quantity. |
Definition at line 331 of file electro.hpp.
|
inlineexplicitconstexpr |
Explicit constructor for lossy precision conversions.
| Rep2 | Source representation type. |
| Precision2 | Source precision. |
| q | The source quantity. |
Definition at line 344 of file electro.hpp.
|
default |
Returns the tick count.
Definition at line 351 of file electro.hpp.
Referenced by electro::level< Reference, Rep, Precision >::count(), electro::operator/(), electro::operator<=>(), electro::operator==(), and electro::to_level().
|
inlinestaticconstexprnoexcept |
Returns the maximum representable quantity.
Definition at line 416 of file electro.hpp.
References electro::quantity< Unit, Rep, Precision >::quantity().
Referenced by electro::level< Reference, Rep, Precision >::max().
|
inlinestaticconstexprnoexcept |
Returns the minimum representable quantity.
Definition at line 413 of file electro.hpp.
References electro::quantity< Unit, Rep, Precision >::quantity().
Referenced by electro::level< Reference, Rep, Precision >::min().
|
inlineconstexpr |
Definition at line 402 of file electro.hpp.
References electro::treat_as_inexact_v.
|
inlineconstexpr |
Definition at line 395 of file electro.hpp.
References electro::treat_as_inexact_v.
|
inlineconstexpr |
Definition at line 385 of file electro.hpp.
References electro::treat_as_inexact_v.
|
inlineconstexpr |
Definition at line 353 of file electro.hpp.
|
inlineconstexpr |
Definition at line 361 of file electro.hpp.
|
inlineconstexpr |
Definition at line 366 of file electro.hpp.
References electro::quantity< Unit, Rep, Precision >::quantity().
|
inlineconstexpr |
Definition at line 375 of file electro.hpp.
References electro::treat_as_inexact_v.
|
inlineconstexpr |
Definition at line 357 of file electro.hpp.
|
inlineconstexpr |
Definition at line 368 of file electro.hpp.
|
inlineconstexpr |
Definition at line 373 of file electro.hpp.
References electro::quantity< Unit, Rep, Precision >::quantity().
|
inlineconstexpr |
Definition at line 380 of file electro.hpp.
References electro::treat_as_inexact_v.
|
inlineconstexpr |
Definition at line 390 of file electro.hpp.
References electro::treat_as_inexact_v.
|
default |
|
inlinestaticconstexprnoexcept |
Returns a zero quantity.
Definition at line 410 of file electro.hpp.
References electro::quantity< Unit, Rep, Precision >::quantity().
Referenced by electro::abs(), and electro::level< Reference, Rep, Precision >::reference_level().