16 sec, min, hour, day, year, ky, My, Gy, Ty, Py,
48 case (energy_units::eV):
50 case (energy_units::keV):
52 case (energy_units::MeV):
54 case (energy_units::GeV):
56 case (energy_units::TeV):
58 case (energy_units::PeV):
60 case (energy_units::unknown_energy_units):
66 "Attempt to compute a scale factor of an unknown unit: \""} +
75 case (time_units::ys):
77 case (time_units::zs):
79 case (time_units::as):
81 case (time_units::fs):
83 case (time_units::ps):
85 case (time_units::ns):
87 case (time_units::us):
89 case (time_units::ms):
91 case (time_units::sec):
93 case (time_units::min):
95 case (time_units::hour):
97 case (time_units::day):
99 case (time_units::year):
101 case (time_units::ky):
103 case (time_units::My):
105 case (time_units::Gy):
107 case (time_units::Ty):
109 case (time_units::Py):
111 case (time_units::Ey):
113 case (time_units::Zy):
115 case (time_units::Yy):
117 case (time_units::unknown_time_units):
123 "Attempt to compute a scale factor of an unknown unit: \""} +
132 template <energy_units U>
struct reference<energy_units, U> {
144 template <time_units U>
struct reference<time_units, U> {
157 static constexpr
auto value =
158 (std::is_class_v<std::decay_t<fields::remove_optional_t<T>>> ||
169 template <
class Field,
class... Subfield>
struct has_units {
170 static constexpr
auto value =
171 !std::is_same_v<typename Field::units_reference_type, units::none> &&
172 is_type_affected_by_units_v<
178 static constexpr
auto value =
179 !std::is_same_v<typename Field::units_reference_type, units::none> &&
180 is_type_affected_by_units_v<typename Field::value_type>;
184 template <
class Field,
class... Subfield>
190 has_units_v<Field, Subfield...>,
196 template <
class Field,
class... Subfield>
203 template <
class Field,
class... Subfield>
209 template <
class T> constexpr
auto const &
operator()(T
const &f)
const {
210 if constexpr (fields::is_optional_v<T>)
218 template <
class Field,
class Subfield,
class... S>
225 if constexpr (fields::is_optional_v<T>)
226 return accessor<Field, S...>(fields::get<Subfield>(f.value()));
228 return accessor<Field, S...>(fields::get<Subfield>(f));
235 template <
class SystemOfUnits,
class T>
238 using R =
typename Field::units_reference_type;
239 using U =
typename R::units_type;
240 return R::scale_factor(sou.template units<U>()) *
246 template <
class Field,
class... Subfield>
constexpr auto const & operator()(T const &f) const
Access a value and process the units.
Definition: units.hpp:209
static constexpr auto scale_factor(energy_units u)
Determine the scale factor from a reference.
Definition: units.hpp:135
static constexpr auto is_type_affected_by_units_v
Whether a type can be affected by units.
Definition: units.hpp:165
std::string to_string(T const &v)
Convert the given object to a string.
Definition: fields.hpp:546
static constexpr auto has_units_v
Whether a subfield must be modified due to the presence of units.
Definition: units.hpp:185
Exceptions that can be thrown when running the functions of the package.
auto scale_factor_for(energy_units u)
Compute the scale factor for the given unit.
Definition: units.hpp:46
typename return_type< Field, Subfield... >::type return_type_t
The return type after taking into account the possible units.
Definition: units.hpp:197
Raised when unexpected problems appear, which should be reported as bugs.
Definition: exceptions.hpp:38
static constexpr accessor_with_units_t< Field, Subfield... > accessor_with_units
Static object to access the fields of a tuple-like object.
Definition: units.hpp:248
energy_units units_type
Definition: units.hpp:133
static constexpr accessor_t< Field, Subfield... > accessor
Static object to access the fields of a tuple-like object.
Definition: units.hpp:200
Use the template argument as a reference to determine scale factors.
Definition: units.hpp:129
static constexpr auto scale_factor(time_units u)
Determine the scale factor from a reference.
Definition: units.hpp:147
Contains macros to define smart enumeration types.
typename field_member_type< Field, Subfield... >::type field_member_type_t
Access the subtype of a set of fields.
Definition: fields.hpp:543
constexpr fields::field_member_type_t< Field, Subfield, S... > const & operator()(T const &f) const
Definition: units.hpp:223
Main namespace of the Reactions package.
Definition: all.hpp:22
The return type after taking into account the possible units.
Definition: units.hpp:188
Object to access fields and process the units.
Definition: units.hpp:233
REACTIONS_POW_ENUM_WITH_UNKNOWN(energy_units, eV, keV, MeV, GeV, TeV, PeV)
Energy units.
Object to access fields.
Definition: units.hpp:200
Whether a type can be affected by units.
Definition: units.hpp:156
Represent the abscence of units.
Definition: units.hpp:43
constexpr return_type_t< Field, Subfield... > operator()(SystemOfUnits const &sou, T const &f) const
Access the value of the subfield and process the units.
Definition: units.hpp:237
time_units units_type
Definition: units.hpp:145
Whether a subfield must be modified due to the presence of units.
Definition: units.hpp:169