Numeric variable proxies with embedded unit of measurement. More...
#include "lardataalg/Utilities/constexpr_math.h"
#include "larcorealg/CoreUtils/MetaUtils.h"
#include "larcorealg/CoreUtils/StdUtils.h"
#include "boost/integer/common_factor_rt.hpp"
#include <ostream>
#include <map>
#include <string>
#include <string_view>
#include <regex>
#include <ratio>
#include <limits>
#include <functional>
#include <type_traits>
#include <cctype>
Go to the source code of this file.
Namespaces | |
util::quantities | |
Types of variables with a unit. | |
util::quantities::concepts | |
Infrastructure for the quantities library. | |
util::quantities::concepts::details | |
util::quantities::prefixes | |
Definitions of additional prefixes. | |
util::quantities::units | |
Definitions of actual units. | |
util::quantities::details | |
Typedefs | |
template<typename R > | |
using | util::quantities::concepts::details::invert_t = typename invert_ratio< R >::type |
template<typename R > | |
using | util::quantities::concepts::details::simplify_ratio = typename ratio_simplifier< R >::type |
template<typename T > | |
using | util::quantities::concepts::details::quantity_value_t = typename quantity_value_type< T >::type |
template<typename ARatio , typename BRatio > | |
using | util::quantities::concepts::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 | util::quantities::concepts::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 | util::quantities::concepts::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 | util::quantities::concepts::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 Ratio , typename Value > | |
static constexpr auto | util::quantities::concepts::details::applyRatioToValue (Value &&v) |
Applies the specified Ratio to the value in v . More... | |
template<typename U , typename R > | |
std::ostream & | util::quantities::concepts::operator<< (std::ostream &out, ScaledUnit< U, R > const &unit) |
template<typename... Args> | |
std::ostream & | util::quantities::concepts::operator<< (std::ostream &out, Quantity< Args... > const q) |
template<typename... Args> | |
std::string | util::quantities::concepts::to_string (ScaledUnit< Args... > const &unit) |
template<typename... Args> | |
std::string | util::quantities::concepts::to_string (Quantity< Args... > const &q) |
template<typename Quantity > | |
std::pair< std::string, typename Quantity::value_t > | util::quantities::details::readUnit (std::string const &str, bool unitOptional=false) |
Parses the unit of a string representing a Quantity . 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 > | util::quantities::concepts::operator+ (Quantity< U, T > const q, T shift)=delete |
template<typename U , typename T > | |
constexpr Quantity< U, T > | util::quantities::concepts::operator+ (T shift, Quantity< U, T > const q)=delete |
template<typename U , typename T > | |
constexpr Quantity< U, T > | util::quantities::concepts::operator- (Quantity< U, T > const q, T shift)=delete |
template<typename U , typename T > | |
constexpr Quantity< U, T > | util::quantities::concepts::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 > > | util::quantities::concepts::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 > > | util::quantities::concepts::operator* (OT factor, Quantity< U, T > const q) |
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 |
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 > > | util::quantities::concepts::operator/ (Quantity< U, T > q, OT quot) |
template<typename Quantity > | |
Quantity | util::quantities::makeQuantity (std::string_view s, bool unitOptional=false) |
Returns a quantity of the specified type parsed from a string. More... | |
template<typename Quantity > | |
Quantity | util::quantities::makeQuantity (std::string const &s, bool unitOptional=false) |
template<typename Quantity > | |
Quantity | util::quantities::makeQuantity (char const *s, bool unitOptional=false) |
Variables | |
template<typename U > | |
constexpr bool | util::quantities::concepts::details::has_unit_v = has_unit<U>() |
Trait: true if U is a ScaledUnit -based object. More... | |
template<typename Q > | |
constexpr bool | util::quantities::concepts::details::is_quantity_v = is_quantity<Q>() |
Trait: true if Q is a Quantity specialization. More... | |
template<typename Q > | |
constexpr bool | util::quantities::concepts::details::has_quantity_v = has_quantity<Q>() |
Trait: true if Q is a Quantity -based object. More... | |
template<typename T , typename Q > | |
constexpr bool | util::quantities::concepts::details::is_value_compatible_with_v = is_value_compatible_with<T, Q>() |
Trait: true if the type T is compatible with the value of Q . More... | |
template<typename T , typename U > | |
constexpr bool | util::quantities::concepts::details::has_value_compatible_with_v = has_value_compatible_with<T, U>() |
Trait: true if the value type of T is compatible with U 's. More... | |
Numeric variable proxies with embedded unit of measurement.
Infrastructure for a library for variables with a given unit of measurement.
Boost::units
? My attempt to use Boost::units
for the implementation (or directly) failed because the quantity
in that library is bound to a dimension without a prefix modifier, e.g. always represents seconds, while we may need nanoseconds. Having a type representing a time in nanoseconds is not trivial, and having two types for representation of time in nanoseconds and microseconds respectively is plain complicate.
On the converse, that library provides arithmetic which is checked for dimensionality correctness. That is beyond the scope of this set of types.
Definition in file quantities.h.