LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
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)
 Multiplication with a scalar. More...
 
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
 Multiplication with a scalar. More...
 
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
 Multiplication with a scalar. More...
 
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)
 Multiplication with a scalar. More...
 
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)
 Returns the product (as scalar) of a time and a frequency. More...
 
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)
 Multiplication with a scalar. More...
 
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 86 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 76 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 913 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 574 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 1023 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 908 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 339 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 335 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 100 of file intervals_fhicl.h.

Referenced by decode(), and fhicl::ParameterSet::get_one_().

101 {
102  using interval_t = Interval<Args...>;
103  using quantity_t = typename interval_t::quantity_t;
104 
105  quantity_t q;
107  iv = interval_t{q};
108 
109 } // 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 71 of file quantities_fhicl.h.

References encode(), and util::to_string().

72 {
73  using quantity_t = Quantity<Args...>;
74 
75  std::string s;
77 
78  q = util::quantities::makeQuantity<quantity_t>(s);
79 
80 } // util::quantities::concepts::decode(Quantity)
void decode(std::any const &src, Quantity< Args... > &q)
Decodes a quantity.
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 113 of file intervals_fhicl.h.

References decode(), encode(), and util::to_string().

114 {
115  using point_t = Point<Args...>;
116  using quantity_t = typename point_t::quantity_t;
117 
118  quantity_t q;
120  pt = point_t{q};
121 
122 } // util::quantities::concepts::decode(Point)
TMarker * pt
Definition: egs.C:25
void decode(std::any const &src, Interval< Args... > &iv)
Decodes an interval.
std::tuple< double, double, const reco::ClusterHit3D * > Point
Definitions used by the VoronoiDiagram algorithm.
Definition: DCEL.h:42
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.

Referenced by decode().

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.

Referenced by decode(), fhicl::detail::encode(), fhicl::ParameterSet::put(), fhicl::ParameterSet::put_or_replace(), and fhicl::ParameterSet::put_or_replace_compatible().

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.

Referenced by decode().

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 459 of file intervals.h.

Referenced by util::quantities::concepts::Quantity< Unit, T >::abs().

460  {
461  return a.quantity() != b;
462  }
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 465 of file intervals.h.

466  {
467  return b != a;
468  }
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 926 of file intervals.h.

927  {
928  return a.quantity() != b;
929  }
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 932 of file intervals.h.

Referenced by util::quantities::concepts::Interval< Q, Cat >::operator!=(), and util::quantities::concepts::Point< Q, Cat, IV >::operator!=().

933  {
934  return b != a;
935  }
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 265 of file frequency.h.

References f.

269 {
270  return details::applyRatioToValue<simplified_ratio_multiply<TR, FR>>(t.value() * f.value());
271 } // util::quantities::operator*(Second, Hertz)
TFile f
Definition: plotHisto.C:6
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 
)

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 212 of file frequency.h.

References f, and operator/().

214  {
215  return t * f;
216  }
TFile f
Definition: plotHisto.C:6
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 537 of file intervals.h.

References util::quantities::concepts::Interval< Q, Cat >::quantity().

Referenced by operator*().

540  {
541  return Interval<Q, Cat>{iv.quantity() * factor};
542  }
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 
)

Multiplication with a scalar.

Definition at line 544 of file intervals.h.

References operator*().

547  {
548  return iv * factor;
549  }
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 868 of file quantities.h.

References util::quantities::concepts::Quantity< Unit, T >::value().

869  {
870  return Quantity<U, T>{q.value() * static_cast<T>(factor)};
871  }
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 
)

Multiplication with a scalar.

Definition at line 874 of file quantities.h.

References operator*().

875  {
876  return q * factor;
877  }
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

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 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

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

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 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 
)

Multiplication with a scalar.

Definition at line 1012 of file intervals.h.

References util::quantities::concepts::Point< Q, Cat, IV >::quantity().

1013  {
1014  return IV(a.quantity() - b.quantity());
1015  }
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 275 of file frequency.h.

279 {
280  return scaled_hertz<details::invert_t<TR>,
281  decltype(std::declval<T>() / std::declval<TT>())>::castFrom(v / t.value());
282 } // util::quantities::operator/(Second)
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 286 of file frequency.h.

References f.

Referenced by operator*().

290 {
291  return scaled_second<details::invert_t<FR>,
292  decltype(std::declval<T>() / std::declval<FT>())>::castFrom(v / f.value());
293 } // util::quantities::operator/(Hertz)
TFile f
Definition: plotHisto.C:6
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 560 of file intervals.h.

References util::quantities::concepts::Interval< Q, Cat >::quantity().

Referenced by util::quantities::concepts::Quantity< Unit, T >::operator value_t().

563  {
564  return Interval<Q, Cat>{iv.quantity() / quot};
565  }
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 891 of file quantities.h.

References util::quantities::concepts::Quantity< Unit, T >::value().

892  {
893  return Quantity<U, T>{q.value() / static_cast<T>(quot)};
894  }
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 483 of file intervals.h.

484  {
485  return a.quantity() < b;
486  }
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 489 of file intervals.h.

490  {
491  return b > a;
492  }
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 950 of file intervals.h.

951  {
952  return a.quantity() < b;
953  }
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 956 of file intervals.h.

Referenced by util::quantities::concepts::Interval< Q, Cat >::operator<(), and util::quantities::concepts::Point< Q, Cat, IV >::operator<().

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

Definition at line 428 of file intervals.h.

References util::quantities::concepts::Interval< Q, Cat >::quantity().

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

Definition at line 477 of file quantities.h.

478  {
479  using unit_t = ScaledUnit<U, R>;
480  return out << unit_t::prefix_t::symbol() << unit_t::baseunit_t::symbol;
481  }
template<typename... Args>
std::ostream& util::quantities::concepts::operator<< ( std::ostream &  out,
Quantity< Args... > const  q 
)

Definition at line 827 of file quantities.h.

References operator+(), operator-(), util::quantities::concepts::Quantity< Unit, T >::unit(), and util::quantities::concepts::Quantity< Unit, T >::value().

828  {
829  return out << q.value() << " " << q.unit();
830  }
template<typename... Args>
std::ostream& util::quantities::concepts::operator<< ( std::ostream &  out,
Point< Args... > const  p 
)

Definition at line 895 of file intervals.h.

References util::quantities::concepts::Point< Q, Cat, IV >::quantity().

896  {
897  return out << p.quantity();
898  }
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 471 of file intervals.h.

472  {
473  return a.quantity() <= b;
474  }
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 477 of file intervals.h.

478  {
479  return b >= a;
480  }
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 938 of file intervals.h.

939  {
940  return a.quantity() <= b;
941  }
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 944 of file intervals.h.

Referenced by util::quantities::concepts::Interval< Q, Cat >::operator<=(), and util::quantities::concepts::Point< Q, Cat, IV >::operator<=().

945  {
946  return b >= a;
947  }
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 447 of file intervals.h.

Referenced by util::quantities::concepts::Quantity< Unit, T >::abs().

448  {
449  return a.quantity() == b;
450  }
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 453 of file intervals.h.

454  {
455  return b == a;
456  }
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 914 of file intervals.h.

915  {
916  return a.quantity() == b;
917  }
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 920 of file intervals.h.

Referenced by util::quantities::concepts::Interval< Q, Cat >::operator==(), and util::quantities::concepts::Point< Q, Cat, IV >::operator==().

921  {
922  return b == a;
923  }
template<typename Q , typename Cat , typename... Args>
constexpr bool util::quantities::concepts::operator> ( Interval< Q, Cat > const  a,
Quantity< Args... > const  b 
)
noexcept
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 513 of file intervals.h.

514  {
515  return b < a;
516  }
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 974 of file intervals.h.

975  {
976  return a.quantity() > b;
977  }
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 980 of file intervals.h.

References operator+(), and operator-().

Referenced by util::quantities::concepts::Interval< Q, Cat >::operator>(), and util::quantities::concepts::Point< Q, Cat, IV >::operator>().

981  {
982  return b < a;
983  }
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 495 of file intervals.h.

Referenced by util::quantities::concepts::Quantity< Unit, T >::abs().

496  {
497  return a.quantity() >= b;
498  }
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 501 of file intervals.h.

502  {
503  return b <= a;
504  }
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 962 of file intervals.h.

963  {
964  return a.quantity() >= b;
965  }
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 968 of file intervals.h.

Referenced by util::quantities::concepts::Interval< Q, Cat >::operator>=(), and util::quantities::concepts::Point< Q, Cat, IV >::operator>=().

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

Definition at line 578 of file intervals.h.

References util::quantities::concepts::Interval< Q, Cat >::quantity(), and util::to_string().

579  {
580  return util::to_string(iv.quantity());
581  }
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 925 of file quantities.h.

References util::quantities::concepts::ScaledUnit< U, R >::baseUnit(), and util::quantities::concepts::ScaledUnit< U, R >::prefix().

926  {
927  return std::string(unit.prefix().symbol()) + unit.baseUnit().symbol.data();
928  }
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 933 of file quantities.h.

References util::quantities::makeQuantity(), util::to_string(), util::quantities::concepts::Quantity< Unit, T >::unit(), and util::quantities::concepts::Quantity< Unit, T >::value().

Referenced by util::quantities::makeQuantity().

934  {
935  return util::to_string(q.value()) + ' ' + util::to_string(q.unit());
936  }
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 1027 of file intervals.h.

References util::quantities::concepts::Point< Q, Cat, IV >::quantity(), and util::to_string().

1028  {
1029  return util::to_string(p.quantity());
1030  }
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 80 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 62 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 71 of file intervals.h.