|
quanta 0.1.0
Type-safe units for temperature, frequency, electrical and spatial quantities, modeled after std::chrono
|
Frequency types and arithmetic, modeled after std::chrono. More...
#include <assert.h>#include <charconv>#include <chrono>#include <cmath>#include <compare>#include <concepts>#include <cstddef>#include <cstdint>#include <cstdlib>#include <limits>#include <quanta/core.hpp>#include <ratio>#include <string>#include <system_error>#include <type_traits>Go to the source code of this file.
Classes | |
| struct | quanta::frequency::is_frequency< T > |
| Trait to detect frequency specializations. More... | |
| struct | quanta::frequency::is_frequency< frequency< Rep, Precision > > |
| class | quanta::frequency::frequency< Rep, Precision > |
| A frequency value with a representation and precision. More... | |
Namespaces | |
| namespace | quanta |
| Type-safe units modeled after std::chrono. | |
| namespace | quanta::frequency |
| Frequency types and utilities. | |
| namespace | std |
| namespace | quanta::literals |
| namespace | quanta::literals::frequency_literals |
Typedefs | |
| using | quanta::frequency::millihertz = frequency< int64_t, std::milli > |
| Frequency with 0.001 Hz (millihertz) precision. | |
| using | quanta::frequency::hertz = frequency< int64_t > |
| Frequency with 1 Hz precision. | |
| using | quanta::frequency::kilohertz = frequency< int64_t, std::kilo > |
| Frequency with 1000 Hz (kilohertz) precision. | |
| using | quanta::frequency::megahertz = frequency< int64_t, std::mega > |
| Frequency with 1,000,000 Hz (megahertz) precision. | |
| using | quanta::frequency::gigahertz = frequency< int64_t, std::giga > |
| Frequency with 1,000,000,000 Hz (gigahertz) precision. | |
| using | quanta::frequency::terahertz = frequency< int64_t, std::tera > |
| Frequency with 1,000,000,000,000 Hz (terahertz) precision. | |
Functions | |
| template<typename ToFreq , typename Rep , typename Precision > requires detail::_quantity_cast_requirements<frequency<Rep, Precision>, ToFreq> | |
| constexpr ToFreq | quanta::frequency::frequency_cast (const frequency< Rep, Precision > &f) |
| Converts a frequency to a different precision or representation. | |
| template<typename ToFreq , typename Rep , typename Precision > | |
| constexpr ToFreq | quanta::frequency::floor (const frequency< Rep, Precision > &f) |
| Converts a frequency to the target type, rounding toward negative infinity. | |
| template<typename ToFreq , typename Rep , typename Precision > | |
| constexpr ToFreq | quanta::frequency::ceil (const frequency< Rep, Precision > &f) |
| Converts a frequency to the target type, rounding toward positive infinity. | |
| template<typename ToFreq , typename Rep , typename Precision > | |
| constexpr ToFreq | quanta::frequency::trunc (const frequency< Rep, Precision > &f) |
| Converts a frequency to the target type, rounding toward zero. | |
| template<typename ToFreq , typename Rep , typename Precision > | |
| constexpr ToFreq | quanta::frequency::round (const frequency< Rep, Precision > &f) |
| Converts a frequency to the target type, rounding to nearest (ties to even). | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::frequency::beat (const frequency< Rep1, Precision1 > &f1, const frequency< Rep2, Precision2 > &f2) -> std::common_type_t< frequency< Rep1, Precision1 >, frequency< Rep2, Precision2 > > |
| Calculates the beat frequency between two frequencies. | |
| template<typename Rep , typename Precision > | |
| constexpr frequency< Rep, Precision > | quanta::frequency::abs (const frequency< Rep, Precision > &f) |
| Returns the absolute value of a frequency. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::frequency::operator+ (const frequency< Rep1, Precision1 > &lhs, const frequency< Rep2, Precision2 > &rhs) -> std::common_type_t< frequency< Rep1, Precision1 >, frequency< Rep2, Precision2 > > |
| Returns the sum of two frequencies. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::frequency::operator- (const frequency< Rep1, Precision1 > &lhs, const frequency< Rep2, Precision2 > &rhs) -> std::common_type_t< frequency< Rep1, Precision1 >, frequency< Rep2, Precision2 > > |
| Returns the difference of two frequencies. | |
| template<typename Rep1 , typename Precision , typename Rep2 > requires not_frequency<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::frequency::operator* (const frequency< Rep1, Precision > &f, const Rep2 &r) -> frequency< std::common_type_t< Rep1, Rep2 >, Precision > |
| Multiplies a frequency by a scalar. | |
| template<typename Rep1 , typename Rep2 , typename Precision > requires not_frequency<Rep1> && std::convertible_to<const Rep1&, std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::frequency::operator* (const Rep1 &r, const frequency< Rep2, Precision > &f) -> frequency< std::common_type_t< Rep1, Rep2 >, Precision > |
| Multiplies a scalar by a frequency. | |
| template<typename Rep1 , typename Precision , typename Rep2 > requires not_frequency<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::frequency::operator/ (const frequency< Rep1, Precision > &f, const Rep2 &s) -> frequency< std::common_type_t< Rep1, Rep2 >, Precision > |
| Divides a frequency by a scalar. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr auto | quanta::frequency::operator/ (const frequency< Rep1, Precision1 > &lhs, const frequency< Rep2, Precision2 > &rhs) -> std::common_type_t< Rep1, Rep2 > |
| Divides two frequencies, returning a scalar. | |
| template<typename Rep1 , typename Precision , typename Rep2 > requires not_frequency<Rep2> && std::convertible_to<const Rep2&, std::common_type_t<Rep1, Rep2>> && (!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>) | |
| constexpr auto | quanta::frequency::operator% (const frequency< Rep1, Precision > &f, const Rep2 &s) -> frequency< std::common_type_t< Rep1, Rep2 >, Precision > |
| Returns the remainder of dividing a frequency by a scalar. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > requires (!treat_as_inexact_v<Rep1> && !treat_as_inexact_v<Rep2>) | |
| constexpr auto | quanta::frequency::operator% (const frequency< Rep1, Precision1 > &lhs, const frequency< Rep2, Precision2 > &rhs) -> std::common_type_t< frequency< Rep1, Precision1 >, frequency< Rep2, Precision2 > > |
| Returns the remainder of dividing two frequencies. | |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > | |
| constexpr bool | quanta::frequency::operator== (const frequency< Rep1, Precision1 > &lhs, const frequency< Rep2, Precision2 > &rhs) |
| template<typename Rep1 , typename Precision1 , typename Rep2 , typename Precision2 > requires std::three_way_comparable<std::common_type_t<Rep1, Rep2>> | |
| constexpr auto | quanta::frequency::operator<=> (const frequency< Rep1, Precision1 > &lhs, const frequency< Rep2, Precision2 > &rhs) |
| template<typename Rep , typename Precision > | |
| std::string | quanta::frequency::to_string (const frequency< Rep, Precision > &f) |
| Converts a frequency to a string with its precision-qualified unit. | |
| template<typename Rep , typename Precision > | |
| std::string | quanta::frequency::to_string (const frequency< Rep, Precision > &f, base_unit_t) |
| Converts a frequency to a string in hertz; see base_unit. | |
| template<typename Rep , typename Precision > | |
| std::string | quanta::frequency::to_string (const frequency< Rep, Precision > &f, scaled_t) |
| Converts a frequency to a string with an SI prefix scaled to its magnitude; see scaled. | |
| template<char... Digits> | |
| constexpr quanta::frequency::millihertz | quanta::literals::frequency_literals::operator""_mHz () |
| Literal for millihertz (e.g., 1000_mHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::hertz | quanta::literals::frequency_literals::operator""_Hz () |
| Literal for hertz (e.g., 1000_Hz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::kilohertz | quanta::literals::frequency_literals::operator""_kHz () |
| Literal for kilohertz (e.g., 80_kHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::megahertz | quanta::literals::frequency_literals::operator""_MHz () |
| Literal for megahertz (e.g., 80_MHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::gigahertz | quanta::literals::frequency_literals::operator""_GHz () |
| Literal for gigahertz (e.g., 2_GHz). | |
| template<char... Digits> | |
| constexpr quanta::frequency::terahertz | quanta::literals::frequency_literals::operator""_THz () |
| Literal for terahertz (e.g., 1_THz). | |
Variables | |
| template<typename T > | |
| constexpr bool | quanta::frequency::is_frequency_v = is_frequency<T>::value |
Frequency types and arithmetic, modeled after std::chrono.
Definition in file frequency.hpp.