Namespaces | Classes | Typedefs | Functions | Variables
util::quantities::concepts Namespace Reference

Infrastructure for the quantities library. More...

Namespaces

 details
 

Classes

struct  CategoryBase
 An non-mandatory base class for interval and point categories. More...
 
struct  Interval
 An interval (duration, length, distance) between two quantity points. More...
 
struct  is_interval
 Trait: true_type if IV is a Interval specialization. More...
 
struct  is_interval< Interval< Args... > >
 
struct  is_point
 Trait: true_type if PT is a Point specialization. More...
 
struct  is_point< Point< Args... > >
 
struct  Point
 A quantity point. More...
 
struct  Prefix
 
struct  Prefix< prefixes::exbi >
 Prefix for 2^60. More...
 
struct  Prefix< prefixes::gibi >
 Prefix for 1073741824 (2^30). More...
 
struct  Prefix< prefixes::kibi >
 Prefix for 1024 (2^10). More...
 
struct  Prefix< prefixes::mebi >
 Prefix for 1048576 (2^20). More...
 
struct  Prefix< prefixes::pebi >
 Prefix for 2^50. More...
 
struct  Prefix< prefixes::tebi >
 Prefix for 2^40. More...
 
struct  Quantity
 A value measured in the specified unit. More...
 
struct  ScaledUnit
 
struct  UnitBase
 

Typedefs

template<typename T >
using is_interval_or_point = std::disjunction< is_interval< T >, is_point< T >>
 Trait: true_type if PT is a specialization of Interval or Point. More...
 
template<typename T >
using interval_of = typename T::interval_t
 Type of interval contained in specified type T. More...
 
template<typename IV , typename R , typename T = typename IV::value_t>
using rescale_interval = Interval< rescale< typename IV::quantity_t, R, T >, typename IV::category_t >
 Type of an interval like IV, but with a different unit scale R. More...
 
template<typename PT , typename R , typename T = typename PT::value_t>
using rescale_point = Point< rescale< typename PT::quantity_t, R, T >, typename PT::category_t >
 Type of a point like PT, but with a different unit scale R. More...
 
template<typename ARatio , typename BRatio >
using simplified_ratio_multiply = details::simplify_ratio< std::ratio_multiply< ARatio, BRatio >>
 A ratio product (like std::ratio_multiply) with simplified terms. More...
 
template<typename NumRatio , typename DenRatio >
using simplified_ratio_divide = details::simplify_ratio< std::ratio_divide< NumRatio, DenRatio >>
 A ratio division (like std::ratio_divide) with simplified terms. More...
 
template<typename Unit , typename Ratio , typename T >
using scaled_quantity = Quantity< ScaledUnit< Unit, Ratio >, T >
 Alias for a quantity based on a scaled unit. More...
 
template<typename Q , typename R , typename T = typename Q::value_t>
using rescale = Quantity< ScaledUnit< typename Q::unit_t::baseunit_t, R >, T >
 Type of a quantity like Q, but with a different unit scale R. More...
 

Functions

template<typename... Args>
std::ostream & operator<< (std::ostream &out, Interval< Args... > const iv)
 
template<typename AQ , typename AC , typename BQ , typename BC >
constexpr auto operator* (Interval< AQ, AC > const, Interval< BQ, BC > const)=delete
 Multiplication between quantities is forbidden. More...
 
template<typename Q , typename Cat , typename T >
constexpr std::enable_if_t< std::is_arithmetic_v< T >, Interval< Q, Cat > > operator/ (Interval< Q, Cat > const iv, T const quot)
 
template<typename Q , typename Cat >
std::string to_string (Interval< Q, Cat > const &iv)
 
template<typename... Args>
std::ostream & operator<< (std::ostream &out, Point< Args... > const p)
 
template<typename Q , typename Cat , typename IV >
std::string to_string (Point< Q, Cat, IV > const &p)
 
template<typename T , typename TR , typename TT >
constexpr auto operator/ (T v, scaled_second< TR, TT > t) -> std::enable_if_t< std::is_convertible_v< T, TT >, scaled_hertz< details::invert_t< TR >, decltype(std::declval< T >()/std::declval< TT >()) > >
 Returns a frequency as the inverse of a time. More...
 
template<typename T , typename FR , typename FT >
constexpr auto operator/ (T v, scaled_hertz< FR, FT > f) -> std::enable_if_t< std::is_convertible_v< T, FT >, scaled_second< details::invert_t< FR >, decltype(std::declval< T >()/std::declval< FT >()) > >
 Returns a time as the inverse of a frequency. More...
 
template<typename U , typename R >
std::ostream & operator<< (std::ostream &out, ScaledUnit< U, R > const &unit)
 
template<typename... Args>
std::ostream & operator<< (std::ostream &out, Quantity< Args... > const q)
 
template<typename... Args>
std::string to_string (ScaledUnit< Args... > const &unit)
 
template<typename... Args>
std::string to_string (Quantity< Args... > const &q)
 
Comparison operations on `Interval`

These operations, as well as the ones implemented as member functions, are provided for convenience.

Here the symmetric operations are defined, where different operands can be swapped.

template<typename Q , typename Cat , typename... Args>
constexpr bool operator== (Interval< Q, Cat > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator== (Quantity< Args... > const a, Interval< Q, Cat > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator!= (Interval< Q, Cat > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator!= (Quantity< Args... > const a, Interval< Q, Cat > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator<= (Interval< Q, Cat > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator<= (Quantity< Args... > const a, Interval< Q, Cat > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator< (Interval< Q, Cat > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator< (Quantity< Args... > const a, Interval< Q, Cat > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator>= (Interval< Q, Cat > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator>= (Quantity< Args... > const a, Interval< Q, Cat > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator> (Interval< Q, Cat > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename... Args>
constexpr bool operator> (Quantity< Args... > const a, Interval< Q, Cat > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator== (Point< Q, Cat, IV > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator== (Quantity< Args... > const a, Point< Q, Cat, IV > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator!= (Point< Q, Cat, IV > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator!= (Quantity< Args... > const a, Point< Q, Cat, IV > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator<= (Point< Q, Cat, IV > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator<= (Quantity< Args... > const a, Point< Q, Cat, IV > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator< (Point< Q, Cat, IV > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator< (Quantity< Args... > const a, Point< Q, Cat, IV > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator>= (Point< Q, Cat, IV > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator>= (Quantity< Args... > const a, Point< Q, Cat, IV > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator> (Point< Q, Cat, IV > const a, Quantity< Args... > const b) noexcept
 
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool operator> (Quantity< Args... > const a, Point< Q, Cat, IV > const b) noexcept
 
Arithmetic operations on `Quantity`

These operations, as well as the ones implemented as member functions, are provided for convenience.

Here the symmetric operations are defined, where different operands can be swapped.

template<typename Q , typename Cat , typename T >
constexpr std::enable_if_t< std::is_arithmetic_v< T >, Interval< Q, Cat > > operator* (Interval< Q, Cat > const iv, T const factor)
 Multiplication with a scalar. More...
 
template<typename Q , typename Cat , typename T >
constexpr std::enable_if_t< std::is_arithmetic_v< T >, Interval< Q, Cat > > operator* (T const factor, Interval< Q, Cat > const iv)
 
template<typename Q , typename Cat , typename IV , typename OQ , typename OC >
constexpr Point< Q, Cat, IV > operator+ (Interval< OQ, OC > const delta, Point< Q, Cat, IV > const p)=delete
 
template<typename Q , typename Cat , typename IV , typename OQ , typename OC >
constexpr Point< Q, Cat, IV > operator- (Interval< OQ, OC > const delta, Point< Q, Cat, IV > const p)=delete
 
template<typename Q , typename Cat , typename IV , typename OQ , typename OCat >
constexpr Point< Q, Cat, IV >::template enable_if_compatible_t< Point< OQ, OCat, IV >, IV > operator- (Point< Q, Cat, IV > const a, Point< OQ, OCat, IV > const b)
 
FHiCL encoding
template<typename... Args>
void decode (std::any const &src, Interval< Args... > &iv)
 Decodes an interval. More...
 
template<typename... Args>
void decode (std::any const &src, Point< Args... > &p)
 Decodes a quantity point. More...
 
template<typename... Args>
::fhicl::detail::ps_atom_t encode (Interval< Args... > const &iv)
 Encodes a quantity interval into a FHiCL parameter set atom. More...
 
template<typename... Args>
::fhicl::detail::ps_atom_t encode (Point< Args... > const &pt)
 Encodes a quantity point into a FHiCL parameter set atom. More...
 
template<typename... Args>
void decode (std::any const &src, Quantity< Args... > &q)
 Decodes a quantity. More...
 
template<typename... Args>
::fhicl::detail::ps_atom_t encode (Quantity< Args... > const &q)
 Encodes a quantity into a FHiCL parameter set atom. More...
 
template<typename TR , typename TT , typename FR , typename FT >
constexpr auto operator* (scaled_quantity< util::quantities::units::Second, TR, TT > t, scaled_quantity< util::quantities::units::Hertz, FR, FT > f) -> decltype(std::declval< TT >()*std::declval< FT >())
 Returns the product (as scalar) of a time and a frequency. More...
 
template<typename FR , typename FT , typename TR , typename TT >
constexpr auto operator* (scaled_quantity< util::quantities::units::Hertz, FR, FT > f, scaled_quantity< util::quantities::units::Second, TR, TT > t)
 
Arithmetic operations on Quantity

These operations, as well as the ones implemented as member functions, are provided for convenience.

Here the symmetric operations are defined, where different operands can be swapped.

template<typename U , typename T >
constexpr Quantity< U, T > operator+ (Quantity< U, T > const q, T shift)=delete
 
template<typename U , typename T >
constexpr Quantity< U, T > operator+ (T shift, Quantity< U, T > const q)=delete
 
template<typename U , typename T >
constexpr Quantity< U, T > operator- (Quantity< U, T > const q, T shift)=delete
 
template<typename U , typename T >
constexpr Quantity< U, T > operator- (T shift, Quantity< U, T > const q)=delete
 
template<typename U , typename T , typename OT >
constexpr std::enable_if_t< Quantity< U, T >::template is_compatible_value_v< OT >, Quantity< U, T > > operator* (Quantity< U, T > const q, OT factor)
 Multiplication with a scalar. More...
 
template<typename U , typename T , typename OT >
constexpr std::enable_if_t< Quantity< U, T >::template is_compatible_value_v< OT >, Quantity< U, T > > operator* (OT factor, Quantity< U, T > const q)
 
template<typename AU , typename AT , typename BU , typename BT >
constexpr auto operator* (Quantity< AU, AT >, Quantity< BU, BT >) -> decltype(std::declval< AT >()*std::declval< BT >())=delete
 Multiplication between quantities is forbidden. More...
 
template<typename U , typename T , typename OT >
constexpr std::enable_if_t< Quantity< U, T >::template is_compatible_value_v< OT >, Quantity< U, T > > operator/ (Quantity< U, T > q, OT quot)
 

Variables

template<typename IV >
constexpr bool is_interval_v = is_interval<IV>()
 Trait: true if IV is a Interval specialization. More...
 
template<typename PT >
constexpr bool is_point_v = is_point<PT>()
 Trait: true if PT is a Point specialization. More...
 
template<typename T >
constexpr bool is_interval_or_point_v = is_interval_or_point<T>()
 Trait: true if PT is a specialization of Interval or Point. More...
 

Detailed Description

Infrastructure for the quantities library.

The namespace concepts contains all the infrastructure for the library, including the definition of classes representing a unit, a quantity, and more.

Typedef Documentation

template<typename T >
using util::quantities::concepts::interval_of = typedef typename T::interval_t

Type of interval contained in specified type T.

Definition at line 94 of file intervals.h.

template<typename T >
using util::quantities::concepts::is_interval_or_point = typedef std::disjunction<is_interval<T>, is_point<T>>

Trait: true_type if PT is a specialization of Interval or Point.

Definition at line 83 of file intervals.h.

template<typename Q , typename R , typename T = typename Q::value_t>
using util::quantities::concepts::rescale = typedef Quantity<ScaledUnit<typename Q::unit_t::baseunit_t, R>, T>

Type of a quantity like Q, but with a different unit scale R.

Definition at line 927 of file quantities.h.

template<typename IV , typename R , typename T = typename IV::value_t>
using util::quantities::concepts::rescale_interval = typedef Interval <rescale<typename IV::quantity_t, R, T>, typename IV::category_t>

Type of an interval like IV, but with a different unit scale R.

Definition at line 532 of file intervals.h.

template<typename PT , typename R , typename T = typename PT::value_t>
using util::quantities::concepts::rescale_point = typedef Point<rescale<typename PT::quantity_t, R, T>, typename PT::category_t>

Type of a point like PT, but with a different unit scale R.

Definition at line 955 of file intervals.h.

template<typename Unit , typename Ratio , typename T >
using util::quantities::concepts::scaled_quantity = typedef Quantity<ScaledUnit<Unit, Ratio>, T>

Alias for a quantity based on a scaled unit.

Template Parameters
Unittype of unit (unscaled)
Ratioscale of the unit for this quantity (e.g. std::milli)
Ttype of value stored

Definition at line 921 of file quantities.h.

template<typename NumRatio , typename DenRatio >
using util::quantities::concepts::simplified_ratio_divide = typedef details::simplify_ratio<std::ratio_divide<NumRatio, DenRatio>>

A ratio division (like std::ratio_divide) with simplified terms.

Definition at line 348 of file quantities.h.

template<typename ARatio , typename BRatio >
using util::quantities::concepts::simplified_ratio_multiply = typedef details::simplify_ratio<std::ratio_multiply<ARatio, BRatio>>

A ratio product (like std::ratio_multiply) with simplified terms.

Definition at line 343 of file quantities.h.

Function Documentation

template<typename... Args>
void util::quantities::concepts::decode ( std::any const &  src,
Interval< Args... > &  iv 
)

Decodes an interval.

Template Parameters
Argstypes defining the interval type
Parameters
srcthe data to decode
ivthe interval where to store the result

This function fills the object iv with information decoded from src.

The decoding happens with util::quantities::makeInterval().

Note
The signature of this function is dictated by FHiCL requirements.

Definition at line 104 of file intervals_fhicl.h.

105 {
106  using interval_t = Interval<Args...>;
107  using quantity_t = typename interval_t::quantity_t;
108 
109  quantity_t q;
111  iv = interval_t{ q };
112 
113 } // util::quantities::concepts::decode(Interval)
void decode(std::any const &src, Interval< Args... > &iv)
Decodes an interval.
template<typename... Args>
void util::quantities::concepts::decode ( std::any const &  src,
Quantity< Args... > &  q 
)

Decodes a quantity.

Template Parameters
Argstypes defining the quantity type
Parameters
srcthe data to decode
qthe quantity where to store the result
Exceptions
std::bad_any_castif src does not provide the necessary data

This function fills the object q with information decoded from src.

The decoding happens with util::quantities::makeQuantity().

Note
The signature of this function is dictated by FHiCL requirements.

Definition at line 75 of file quantities_fhicl.h.

76 {
77  using quantity_t = Quantity<Args...>;
78 
79  std::string s;
81 
82  q = util::quantities::makeQuantity<quantity_t>(s);
83 
84 } // util::quantities::concepts::decode(Quantity)
std::string string
Definition: nybbler.cc:12
void decode(std::any const &src, Quantity< Args... > &q)
Decodes a quantity.
static QCString * s
Definition: config.cpp:1042
template<typename... Args>
void util::quantities::concepts::decode ( std::any const &  src,
Point< Args... > &  p 
)

Decodes a quantity point.

Template Parameters
Argstypes defining the quantity point type
Parameters
srcthe data to decode
pthe quantity point where to store the result

This function fills the object iv with information decoded from src.

The decoding happens with util::quantities::makePoint().

Note
The signature of this function is dictated by FHiCL requirements.

Definition at line 119 of file intervals_fhicl.h.

120 {
121  using point_t = Point<Args...>;
122  using quantity_t = typename point_t::quantity_t;
123 
124  quantity_t q;
126  pt = point_t{ q };
127 
128 } // util::quantities::concepts::decode(Point)
void decode(std::any const &src, Interval< Args... > &iv)
Decodes an interval.
template<typename... Args>
::fhicl::detail::ps_atom_t util::quantities::concepts::encode ( Quantity< Args... > const &  q)

Encodes a quantity into a FHiCL parameter set atom.

Template Parameters
Argstypes defining the quantity type
Parameters
qthe quantity to be encoded
Returns
the quantity encoded into a FHiCL parameter set atom

This function returns a parameter set atom with the content of the quantity q.

Note
The signature of this function is dictated by FHiCL requirements.
template<typename... Args>
::fhicl::detail::ps_atom_t util::quantities::concepts::encode ( Interval< Args... > const &  iv)

Encodes a quantity interval into a FHiCL parameter set atom.

Template Parameters
Argstypes defining the quantity interval type
Parameters
ivthe interval to be encoded
Returns
the interval encoded into a FHiCL parameter set atom

This function returns a parameter set atom with the content of the quantity interval iv.

Note
The signature of this function is dictated by FHiCL requirements.
template<typename... Args>
::fhicl::detail::ps_atom_t util::quantities::concepts::encode ( Point< Args... > const &  pt)

Encodes a quantity point into a FHiCL parameter set atom.

Template Parameters
Argstypes defining the quantity point type
Parameters
ptthe quantity point to be encoded
Returns
the point encoded into a FHiCL parameter set atom

This function returns a parameter set atom with the content of the quantity point p.

Note
The signature of this function is dictated by FHiCL requirements.
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator!= ( Interval< Q, Cat > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 436 of file intervals.h.

437  { return a.quantity() != b; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator!= ( Quantity< Args... > const  a,
Interval< Q, Cat > const  b 
)
noexcept

Definition at line 441 of file intervals.h.

442  { return b != a; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator!= ( Point< Q, Cat, IV > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 864 of file intervals.h.

865  { return a.quantity() != b; }
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator!= ( Quantity< Args... > const  a,
Point< Q, Cat, IV > const  b 
)
noexcept

Definition at line 869 of file intervals.h.

870  { return b != a; }
const double a
template<typename TR , typename TT , typename FR , typename FT >
constexpr auto util::quantities::concepts::operator* ( scaled_quantity< util::quantities::units::Second, TR, TT >  t,
scaled_quantity< util::quantities::units::Hertz, FR, FT >  f 
) -> decltype(std::declval<TT>() * std::declval<FT>())

Returns the product (as scalar) of a time and a frequency.

Template Parameters
TRtype of time unit scale (e.g. std::micro)
TTtype of time value representation
FRtype of frequency unit scale (e.g. std::mega)
FTtype of frequency value representation
Parameters
ttime quantity, based on util::quantities::units::Second
ffrequency quantity, based on util::quantities::units::Hertz
Returns
the product of the two (using the C++ type of TT * FT)

Definition at line 274 of file frequency.h.

279 {
280  return details::applyRatioToValue<simplified_ratio_multiply<TR, FR> >
281  (t.value() * f.value());
282 } // util::quantities::operator*(Second, Hertz)
template<typename FR , typename FT , typename TR , typename TT >
constexpr auto util::quantities::concepts::operator* ( scaled_quantity< util::quantities::units::Hertz, FR, FT >  f,
scaled_quantity< util::quantities::units::Second, TR, TT >  t 
)

Definition at line 205 of file frequency.h.

template<typename Q , typename Cat , typename T >
constexpr std::enable_if_t<std::is_arithmetic_v<T>, Interval<Q, Cat> > util::quantities::concepts::operator* ( Interval< Q, Cat > const  iv,
T const  factor 
)

Multiplication with a scalar.

Definition at line 505 of file intervals.h.

506  { return Interval<Q, Cat>{ iv.quantity() * factor }; }
template<typename Q , typename Cat , typename T >
constexpr std::enable_if_t<std::is_arithmetic_v<T>, Interval<Q, Cat> > util::quantities::concepts::operator* ( T const  factor,
Interval< Q, Cat > const  iv 
)

Definition at line 509 of file intervals.h.

509 { return iv * factor; }
template<typename AQ , typename AC , typename BQ , typename BC >
constexpr auto util::quantities::concepts::operator* ( Interval< AQ, AC >  const,
Interval< BQ, BC >  const 
)
delete

Multiplication between quantities is forbidden.

template<typename U , typename T , typename OT >
constexpr std::enable_if_t<Quantity<U, T>::template is_compatible_value_v<OT>, Quantity<U, T> > util::quantities::concepts::operator* ( Quantity< U, T > const  q,
OT  factor 
)

Multiplication with a scalar.

Definition at line 881 of file quantities.h.

882  { return Quantity<U, T>{ q.value() * static_cast<T>(factor) }; }
template<typename U , typename T , typename OT >
constexpr std::enable_if_t<Quantity<U, T>::template is_compatible_value_v<OT>, Quantity<U, T> > util::quantities::concepts::operator* ( OT  factor,
Quantity< U, T > const  q 
)

Definition at line 887 of file quantities.h.

888  { return q * factor; }
template<typename AU , typename AT , typename BU , typename BT >
constexpr auto util::quantities::concepts::operator* ( Quantity< AU, AT >  ,
Quantity< BU, BT >   
) -> decltype(std::declval< AT >()*std::declval< BT >())=delete
delete

Multiplication between quantities is forbidden.

template<typename U , typename T >
constexpr Quantity<U, T> util::quantities::concepts::operator+ ( Quantity< U, T > const  q,
shift 
)
delete

Addition and subtraction of a quantity and a plain number are forbidden.

The rationale is that it is not acceptable to support position + 2_m but not 2_m + position, and that it is not acceptable to have 2_m + 50_cm yield a type different than 50_cm + 2_m (i.e. should both return centimeters, or meters?).

template<typename U , typename T >
constexpr Quantity<U, T> util::quantities::concepts::operator+ ( shift,
Quantity< U, T > const  q 
)
delete
template<typename Q , typename Cat , typename IV , typename OQ , typename OC >
constexpr Point<Q, Cat, IV> util::quantities::concepts::operator+ ( Interval< OQ, OC > const  delta,
Point< Q, Cat, IV > const  p 
)
delete
template<typename U , typename T >
constexpr Quantity<U, T> util::quantities::concepts::operator- ( Quantity< U, T > const  q,
shift 
)
delete
template<typename U , typename T >
constexpr Quantity<U, T> util::quantities::concepts::operator- ( shift,
Quantity< U, T > const  q 
)
delete
template<typename Q , typename Cat , typename IV , typename OQ , typename OC >
constexpr Point<Q, Cat, IV> util::quantities::concepts::operator- ( Interval< OQ, OC > const  delta,
Point< Q, Cat, IV > const  p 
)
delete
template<typename Q , typename Cat , typename IV , typename OQ , typename OCat >
constexpr Point<Q, Cat, IV>::template enable_if_compatible_t<Point<OQ, OCat, IV>, IV> util::quantities::concepts::operator- ( Point< Q, Cat, IV > const  a,
Point< OQ, OCat, IV > const  b 
)

Definition at line 944 of file intervals.h.

945  { return IV(a.quantity() - b.quantity()); }
template<typename T , typename TR , typename TT >
constexpr auto util::quantities::concepts::operator/ ( v,
scaled_second< TR, TT >  t 
) -> std::enable_if_t< std::is_convertible_v<T, TT>, scaled_hertz< details::invert_t<TR>, decltype(std::declval<T>() / std::declval<TT>()) > >

Returns a frequency as the inverse of a time.

Template Parameters
Ttype of pure number
TRtype of time unit scale (e.g. std::micro)
TTtype of time value representation
Parameters
vscalar value to be divided
ttime quantity, based on util::quantities::unit::Second
Returns
a frequency f so that f * t equals v

The scale of the frequency unit is the inverse of the time one (e.g., a division by util::quantities::millisecond gives util::quantities::kilohertz).

Definition at line 288 of file frequency.h.

294 {
295  return scaled_hertz
296  <details::invert_t<TR>, decltype(std::declval<T>() / std::declval<TT>())>
297  ::castFrom(v / t.value());
298 } // util::quantities::operator/(Second)
concepts::scaled_quantity< units::Hertz, R, T > scaled_hertz
The most generic units::Hertz-based quantity.
Definition: frequency.h:71
template<typename T , typename FR , typename FT >
constexpr auto util::quantities::concepts::operator/ ( v,
scaled_hertz< FR, FT >  f 
) -> std::enable_if_t< std::is_convertible_v<T, FT>, scaled_second< details::invert_t<FR>, decltype(std::declval<T>() / std::declval<FT>()) > >

Returns a time as the inverse of a frequency.

Template Parameters
Ttype of pure number
FRtype of frequency unit scale (e.g. std::mega)
FTtype of frequency value representation
Parameters
vscalar value to be divided
tfrequency quantity, based on util::quantities::unit::Hertz
Returns
a time t so that t * f equals v

The scale of the time unit is the inverse of the frequency one (e.g., a division by util::quantities::kilohertz gives util::quantities::millisecond).

Definition at line 304 of file frequency.h.

310 {
311  return scaled_second
312  <details::invert_t<FR>, decltype(std::declval<T>() / std::declval<FT>())>
313  ::castFrom( v / f.value() );
314 } // util::quantities::operator/(Hertz)
concepts::scaled_quantity< units::Second, R, T > scaled_second
The most generic units::Second-based quantity.
Definition: spacetime.h:71
template<typename Q , typename Cat , typename T >
constexpr std::enable_if_t<std::is_arithmetic_v<T>, Interval<Q, Cat> > util::quantities::concepts::operator/ ( Interval< Q, Cat > const  iv,
T const  quot 
)

Definition at line 521 of file intervals.h.

522  { return Interval<Q, Cat>{ iv.quantity() / quot }; }
template<typename U , typename T , typename OT >
constexpr std::enable_if_t<Quantity<U, T>::template is_compatible_value_v<OT>, Quantity<U, T> > util::quantities::concepts::operator/ ( Quantity< U, T >  q,
OT  quot 
)

Definition at line 905 of file quantities.h.

906  { return Quantity<U, T>{ q.value() / static_cast<T>(quot) }; }
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator< ( Interval< Q, Cat > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 456 of file intervals.h.

457  { return a.quantity() < b; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator< ( Quantity< Args... > const  a,
Interval< Q, Cat > const  b 
)
noexcept

Definition at line 461 of file intervals.h.

462  { return b > a; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator< ( Point< Q, Cat, IV > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 884 of file intervals.h.

885  { return a.quantity() < b; }
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator< ( Quantity< Args... > const  a,
Point< Q, Cat, IV > const  b 
)
noexcept

Definition at line 889 of file intervals.h.

890  { return b > a; }
const double a
template<typename... Args>
std::ostream& util::quantities::concepts::operator<< ( std::ostream &  out,
Interval< Args... > const  iv 
)

Definition at line 407 of file intervals.h.

408  { return out << iv.quantity(); }
template<typename U , typename R >
std::ostream& util::quantities::concepts::operator<< ( std::ostream &  out,
ScaledUnit< U, R > const &  unit 
)

Definition at line 488 of file quantities.h.

489  {
490  using unit_t = ScaledUnit<U, R>;
491  return out << unit_t::prefix_t::symbol() << unit_t::baseunit_t::symbol;
492  }
template<typename... Args>
std::ostream& util::quantities::concepts::operator<< ( std::ostream &  out,
Point< Args... > const  p 
)

Definition at line 834 of file intervals.h.

835  { return out << p.quantity(); }
template<typename... Args>
std::ostream& util::quantities::concepts::operator<< ( std::ostream &  out,
Quantity< Args... > const  q 
)

Definition at line 835 of file quantities.h.

836  { return out << q.value() << " " << q.unit(); }
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator<= ( Interval< Q, Cat > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 446 of file intervals.h.

447  { return a.quantity() <= b; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator<= ( Quantity< Args... > const  a,
Interval< Q, Cat > const  b 
)
noexcept

Definition at line 451 of file intervals.h.

452  { return b >= a; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator<= ( Point< Q, Cat, IV > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 874 of file intervals.h.

875  { return a.quantity() <= b; }
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator<= ( Quantity< Args... > const  a,
Point< Q, Cat, IV > const  b 
)
noexcept

Definition at line 879 of file intervals.h.

880  { return b >= a; }
const double a
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator== ( Interval< Q, Cat > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 426 of file intervals.h.

427  { return a.quantity() == b; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator== ( Quantity< Args... > const  a,
Interval< Q, Cat > const  b 
)
noexcept

Definition at line 431 of file intervals.h.

432  { return b == a; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator== ( Point< Q, Cat, IV > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 854 of file intervals.h.

855  { return a.quantity() == b; }
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator== ( Quantity< Args... > const  a,
Point< Q, Cat, IV > const  b 
)
noexcept

Definition at line 859 of file intervals.h.

860  { return b == a; }
const double a
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator> ( Interval< Q, Cat > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 476 of file intervals.h.

477  { return a.quantity() > b; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator> ( Quantity< Args... > const  a,
Interval< Q, Cat > const  b 
)
noexcept

Definition at line 481 of file intervals.h.

482  { return b < a; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator> ( Point< Q, Cat, IV > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 904 of file intervals.h.

905  { return a.quantity() > b; }
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator> ( Quantity< Args... > const  a,
Point< Q, Cat, IV > const  b 
)
noexcept

Definition at line 909 of file intervals.h.

910  { return b < a; }
const double a
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator>= ( Interval< Q, Cat > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 466 of file intervals.h.

467  { return a.quantity() >= b; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator>= ( Quantity< Args... > const  a,
Interval< Q, Cat > const  b 
)
noexcept

Definition at line 471 of file intervals.h.

472  { return b <= a; }
const double a
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator>= ( Point< Q, Cat, IV > const  a,
Quantity< Args... > const  b 
)
noexcept

Definition at line 894 of file intervals.h.

895  { return a.quantity() >= b; }
static bool * b
Definition: config.cpp:1043
template<typename Q , typename Cat , typename IV , typename... Args>
constexpr bool util::quantities::concepts::operator>= ( Quantity< Args... > const  a,
Point< Q, Cat, IV > const  b 
)
noexcept

Definition at line 899 of file intervals.h.

900  { return b <= a; }
const double a
template<typename Q , typename Cat >
std::string util::quantities::concepts::to_string ( Interval< Q, Cat > const &  iv)

Definition at line 537 of file intervals.h.

538  { return util::to_string(iv.quantity()); }
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
template<typename... Args>
std::string util::quantities::concepts::to_string ( ScaledUnit< Args... > const &  unit)

Converts a unit into a string.

See also
util::to_string()

Definition at line 940 of file quantities.h.

941  {
942  return
943  std::string(unit.prefix().symbol()) + unit.baseUnit().symbol.data();
944  }
std::string string
Definition: nybbler.cc:12
template<typename... Args>
std::string util::quantities::concepts::to_string ( Quantity< Args... > const &  q)

Converts a quantity into a string.

See also
util::to_string()

Definition at line 949 of file quantities.h.

950  { return util::to_string(q.value()) + ' ' + util::to_string(q.unit()); }
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.
template<typename Q , typename Cat , typename IV >
std::string util::quantities::concepts::to_string ( Point< Q, Cat, IV > const &  p)

Definition at line 960 of file intervals.h.

961  { return util::to_string(p.quantity()); }
decltype(auto) constexpr to_string(T &&obj)
ADL-aware version of std::to_string.

Variable Documentation

template<typename T >
constexpr bool util::quantities::concepts::is_interval_or_point_v = is_interval_or_point<T>()

Trait: true if PT is a specialization of Interval or Point.

Definition at line 87 of file intervals.h.

template<typename IV >
constexpr bool util::quantities::concepts::is_interval_v = is_interval<IV>()

Trait: true if IV is a Interval specialization.

Definition at line 67 of file intervals.h.

template<typename PT >
constexpr bool util::quantities::concepts::is_point_v = is_point<PT>()

Trait: true if PT is a Point specialization.

Definition at line 77 of file intervals.h.