LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
util::quantities::concepts::ScaledUnit< U, R > Struct Template Reference

#include "quantities.h"

Public Types

using baseunit_t = U
 Base, unscaled unit. More...
 
using unit_t = ScaledUnit< U, R >
 Unit with scale (i.e. this object). More...
 
using ratio = R
 The ratio to go from the base unit to this one. More...
 
using prefix_t = Prefix< ratio >
 The prefix of the unit. More...
 

Static Public Member Functions

Conversion to string.
Note
Implementation note: the returned values (currently std::string_view) are not constexpr since it takes noticeable additional effort to make them so.
static auto symbol ()
 Returns short symbol of the unit (e.g. "ns") is a string-like object. More...
 
static auto name ()
 
Representation conversions.
template<typename T >
static constexpr T scale (T v)
 Converts a value from the base unit to this one. More...
 
template<typename T >
static constexpr T unscale (T v)
 Converts a value from this scaled unit to the base one. More...
 
template<typename TargetRatio , typename T >
static constexpr T scaleTo (T v)
 Converts a value from the scaled unit to a different TargetRatio. More...
 
template<typename TargetRatio , typename T >
static constexpr T fromRepr (T v)
 Converts a value from TargetRatio scale to this scaled unit. More...
 
Type features
static constexpr prefix_t prefix ()
 Returns an instance of the prefix_t type. More...
 
static constexpr baseunit_t baseUnit ()
 Returns an instance of the baseunit_t type. More...
 
static constexpr unit_t unit ()
 Returns an instance of the unit_t type. More...
 
template<typename OU >
static constexpr bool sameBaseUnitAs ()
 Returns whether scaled unit U has the same base unit as this one. More...
 
template<typename OU >
static constexpr bool sameUnitAs ()
 Returns whether scaled unit U has the same base unit as this one. More...
 

Detailed Description

template<typename U, typename R = std::ratio<1>>
struct util::quantities::concepts::ScaledUnit< U, R >

Definition at line 382 of file quantities.h.

Member Typedef Documentation

template<typename U, typename R = std::ratio<1>>
using util::quantities::concepts::ScaledUnit< U, R >::baseunit_t = U

Base, unscaled unit.

Definition at line 384 of file quantities.h.

template<typename U, typename R = std::ratio<1>>
using util::quantities::concepts::ScaledUnit< U, R >::prefix_t = Prefix<ratio>

The prefix of the unit.

Definition at line 387 of file quantities.h.

template<typename U, typename R = std::ratio<1>>
using util::quantities::concepts::ScaledUnit< U, R >::ratio = R

The ratio to go from the base unit to this one.

Definition at line 386 of file quantities.h.

template<typename U, typename R = std::ratio<1>>
using util::quantities::concepts::ScaledUnit< U, R >::unit_t = ScaledUnit<U, R>

Unit with scale (i.e. this object).

Definition at line 385 of file quantities.h.

Member Function Documentation

template<typename U, typename R = std::ratio<1>>
static constexpr baseunit_t util::quantities::concepts::ScaledUnit< U, R >::baseUnit ( )
inlinestatic

Returns an instance of the baseunit_t type.

Definition at line 452 of file quantities.h.

Referenced by util::quantities::concepts::to_string().

452 { return {}; }
template<typename U, typename R = std::ratio<1>>
template<typename TargetRatio , typename T >
static constexpr T util::quantities::concepts::ScaledUnit< U, R >::fromRepr ( v)
inlinestatic

Converts a value from TargetRatio scale to this scaled unit.

Definition at line 436 of file quantities.h.

437  {
438  return details::applyRatioToValue<simplified_ratio_divide<TargetRatio, ratio>>(v);
439  }
template<typename U, typename R = std::ratio<1>>
static auto util::quantities::concepts::ScaledUnit< U, R >::name ( )
inlinestatic

Returns full name of the unit (e.g. "nanoseconds") as a string-like object.

Definition at line 404 of file quantities.h.

References util::quantities::concepts::ScaledUnit< U, R >::name().

Referenced by util::quantities::concepts::ScaledUnit< U, R >::name().

404 { return std::string(prefix().name()) + baseUnit().name.data(); }
static constexpr baseunit_t baseUnit()
Returns an instance of the baseunit_t type.
Definition: quantities.h:452
static constexpr prefix_t prefix()
Returns an instance of the prefix_t type.
Definition: quantities.h:449
template<typename U, typename R = std::ratio<1>>
static constexpr prefix_t util::quantities::concepts::ScaledUnit< U, R >::prefix ( )
inlinestatic

Returns an instance of the prefix_t type.

Definition at line 449 of file quantities.h.

Referenced by util::quantities::concepts::to_string().

449 { return {}; }
template<typename U, typename R = std::ratio<1>>
template<typename OU >
static constexpr bool util::quantities::concepts::ScaledUnit< U, R >::sameBaseUnitAs ( )
inlinestatic

Returns whether scaled unit U has the same base unit as this one.

Definition at line 459 of file quantities.h.

460  {
461  return std::is_same<baseunit_t, typename OU::baseunit_t>();
462  }
template<typename U, typename R = std::ratio<1>>
template<typename OU >
static constexpr bool util::quantities::concepts::ScaledUnit< U, R >::sameUnitAs ( )
inlinestatic

Returns whether scaled unit U has the same base unit as this one.

Definition at line 466 of file quantities.h.

467  {
468  return std::is_same<unit_t, typename OU::unit_t>();
469  }
template<typename U, typename R = std::ratio<1>>
template<typename T >
static constexpr T util::quantities::concepts::ScaledUnit< U, R >::scale ( v)
inlinestatic

Converts a value from the base unit to this one.

Definition at line 415 of file quantities.h.

416  {
417  return details::applyRatioToValue<details::invert_t<ratio>>(v);
418  }
template<typename U, typename R = std::ratio<1>>
template<typename TargetRatio , typename T >
static constexpr T util::quantities::concepts::ScaledUnit< U, R >::scaleTo ( v)
inlinestatic

Converts a value from the scaled unit to a different TargetRatio.

Definition at line 429 of file quantities.h.

430  {
431  return details::applyRatioToValue<simplified_ratio_divide<ratio, TargetRatio>>(v);
432  }
template<typename U, typename R = std::ratio<1>>
static auto util::quantities::concepts::ScaledUnit< U, R >::symbol ( )
inlinestatic

Returns short symbol of the unit (e.g. "ns") is a string-like object.

Definition at line 400 of file quantities.h.

References util::quantities::concepts::ScaledUnit< U, R >::symbol().

Referenced by util::quantities::concepts::ScaledUnit< U, R >::symbol().

400 { return std::string(prefix().symbol()) + baseUnit().symbol.data(); }
static auto symbol()
Returns short symbol of the unit (e.g. "ns") is a string-like object.
Definition: quantities.h:400
static constexpr baseunit_t baseUnit()
Returns an instance of the baseunit_t type.
Definition: quantities.h:452
static constexpr prefix_t prefix()
Returns an instance of the prefix_t type.
Definition: quantities.h:449
template<typename U, typename R = std::ratio<1>>
static constexpr unit_t util::quantities::concepts::ScaledUnit< U, R >::unit ( )
inlinestatic

Returns an instance of the unit_t type.

Definition at line 455 of file quantities.h.

455 { return {}; }
template<typename U, typename R = std::ratio<1>>
template<typename T >
static constexpr T util::quantities::concepts::ScaledUnit< U, R >::unscale ( v)
inlinestatic

Converts a value from this scaled unit to the base one.

Definition at line 422 of file quantities.h.

423  {
424  return details::applyRatioToValue<ratio>(v);
425  }

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