24 constexpr
fill(Args &&...args) :
base_type{std::forward<Args>(args)...} {}
28 static constexpr
auto missing = std::nullopt;
69 template <
class Fields>
82 template <
class Field,
class Enable =
void>
86 template <
class Field>
88 Field, std::enable_if_t<is_optional_v<typename Field::value_type>>>
92 template <
class Field>
119 template <std::
size_t Min, std::
size_t Max>
struct range {
120 static constexpr
auto min = Min, max = Max;
132 template <
class R0,
class... R,
class Rn>
146 std::enable_if_t<std::is_floating_point_v<T>, void>> {
154 template <
class Value,
class Error>
158 template <
class Value,
class Error>
169 template <
class ValueType,
class TagType,
class Enable =
void>
173 template <
class ValueType,
class TagType>
176 std::enable_if_t<(std::is_floating_point_v<ValueType> &&
177 std::is_integral_v<TagType>),
186 template <
class Value,
class Error>
190 template <
class Value,
class Error>
192 :
base_type{std::get<0>(f), std::get<1>(f)},
tag(std::get<2>(f)) {}
204 std::enable_if_t<std::is_floating_point_v<T>, void>> {
211 template <
class Value,
class ErrorLower,
class ErrorUpper>
213 ErrorUpper error_upper_)
216 template <
class Value,
class ErrorLower,
class ErrorUpper>
229 return error_lower * error_lower + error_upper * error_upper;
248 template <
class Field>
struct get_t;
252 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
259 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
266 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
273 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
280 template <
class T> constexpr
auto const &
operator()(T
const &t)
const {
286 template <
class T,
class Subfield,
class... S>
struct type_of {
291 template <
class T,
class Subfield>
struct type_of<T, Subfield> {
298 template <
class T,
class... Subfield>
304 return {f * vae.value, f * vae.error};
314 template <
class V,
class T>
317 return {f * vae.value, f * vae.error, vae.tag};
321 template <
class V,
class T>
330 return {f * vae.value, f * vae.error_lower, f * vae.error_upper};
352 template <
class TagType>
356 template <
class TagType>
447 template <
class Range,
class T>
462 template <
class Ranges,
class T>
466 static_assert(std::tuple_size_v<Ranges> == 3);
470 if (b >= std::tuple_element_t<1, Ranges>::max)
473 auto value_sc = read_field<std::tuple_element_t<0, Ranges>>(out.value, s);
474 auto error_sc = read_field<std::tuple_element_t<1, Ranges>>(out.error, s);
485 template <
class Ranges,
class ValueType,
class TagType>
491 static_assert(std::tuple_size_v<Ranges> == 3);
495 if (b >= std::tuple_element_t<2, Ranges>::max)
498 auto value_sc = read_field<std::tuple_element_t<0, Ranges>>(out.value, s);
499 auto error_sc = read_field<std::tuple_element_t<1, Ranges>>(out.error, s);
500 auto tag_sc = read_field<std::tuple_element_t<2, Ranges>>(out.tag, s);
511 template <
class Ranges,
class T>
515 static_assert(std::tuple_size_v<Ranges> == 3);
519 if (b >= std::tuple_element_t<2, Ranges>::max)
522 auto value_sc = read_field<std::tuple_element_t<0, Ranges>>(out.value, s);
523 auto error_lower_sc =
524 read_field<std::tuple_element_t<1, Ranges>>(out.error_lower, s);
525 auto error_upper_sc =
526 read_field<std::tuple_element_t<2, Ranges>>(out.error_upper, s);
528 if (value_sc ==
empty || error_lower_sc ==
empty || error_upper_sc ==
empty)
530 else if (value_sc ==
failed || error_lower_sc ==
failed ||
549 template <
class Field,
class... Subfield>
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:252
value_and_errors(fill< Value, ErrorLower, ErrorUpper > &&f)
Build the class from a field constant expression.
Definition: fields.hpp:217
Field for an error.
Definition: fields.hpp:110
value_type error_upper
Upper error.
Definition: fields.hpp:226
Define a range with minimum and maximum indices.
Definition: fields.hpp:119
Type defining an accessor to a value/error field.
Definition: fields.hpp:248
value_type error_squared() const
Calculate the squared error from the lower and upper errors.
Definition: fields.hpp:228
the conversion succeeded
Definition: fields.hpp:366
remove_optional_t< typename Field::value_type > type
Definition: fields.hpp:545
Field for a lower error.
Definition: fields.hpp:112
value_type error() const
Calculate the error from the lower and upper errors.
Definition: fields.hpp:232
T find_first_not_of(T... args)
T type
Definition: fields.hpp:96
value_type value
Value.
Definition: fields.hpp:222
typename type_of< T, Subfield... >::type type_of_t
Determine a returned type.
Definition: fields.hpp:299
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:266
static constexpr auto missing
Static object that defines a missing field within an object.
Definition: fields.hpp:28
value_and_errors(Value value_, ErrorLower error_lower_, ErrorUpper error_upper_)
Build the class with forwarded arguments.
Definition: fields.hpp:212
Contain the information whether a field is optional or not.
Definition: fields.hpp:83
Determine a returned type.
Definition: fields.hpp:286
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:280
the conversion failed
Definition: fields.hpp:368
T value_type
Definition: fields.hpp:206
value_and_error_with_tag(Value value_, Error error_, TagType tag_)
Build the class with forwarded arguments.
Definition: fields.hpp:187
Access the subtype of a set of fields.
Definition: fields.hpp:538
typename remove_optional< T >::type remove_optional_t
If the input type is an optional, get the underying type.
Definition: fields.hpp:105
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:259
Small structure to define fields without explicitely knowing its type.
Definition: fields.hpp:21
typename underlying_types< Fields >::type underlying_types_t
Define a std::tuple with the types of the fields provided.
Definition: fields.hpp:70
value_type error
Error.
Definition: fields.hpp:165
Define a std::tuple with the types of the fields provided.
Definition: fields.hpp:61
typename type_of< Subfield, S... >::type type
Definition: fields.hpp:287
conversion_status string_to_type(std::string &out, std::string const &s)
Convert a range of characters to string.
Definition: fields.hpp:435
typename field_member_type< Field, Subfield... >::type field_member_type_t
Access the subtype of a set of fields.
Definition: fields.hpp:551
typename overall_range< R >::type overall_range_t
Overall range of a variable (that can be a composite)
Definition: fields.hpp:138
Main namespace of the Reactions package.
Definition: all.hpp:22
T type
Definition: fields.hpp:100
value_and_error_with_tag(fill< Value, Error, TagType > &&f)
Build the class from a field constant expression.
Definition: fields.hpp:191
Field for an lower error.
Definition: fields.hpp:114
value_and_errors< T > operator*(T f, value_and_errors< T > const &vae)
Multiplication of the value and errors by a constant.
Definition: fields.hpp:335
Check if a type represents an optional.
Definition: fields.hpp:73
value_type error_lower
Lower error.
Definition: fields.hpp:224
Simple structure composed by a value and its error.
Definition: fields.hpp:141
constexpr auto const & operator()(T const &t) const
Definition: fields.hpp:273
value_and_error(fill< Value, Error > &&f)
Build the class from a field constant expression.
Definition: fields.hpp:159
T find_last_not_of(T... args)
value_type value
Value.
Definition: fields.hpp:163
constexpr auto is_optional_v
Alias to check if a type represents an optional.
Definition: fields.hpp:79
the object is missing
Definition: fields.hpp:367
conversion_status read_field(value_and_errors< T > &out, std::string const &s)
Read a field composed by value and errors in a line from a file.
Definition: fields.hpp:512
constexpr fill(Args &&...args)
Definition: fields.hpp:24
value_and_error(Value value_, Error error_)
Build the class with forwarded arguments.
Definition: fields.hpp:155
Represent a value, its error and a identifier tag.
Definition: fields.hpp:170
Field for a value.
Definition: fields.hpp:108
conversion_status
Status code of a conversion to an arithmetic or std::optional type.
Definition: fields.hpp:365
Simple structure composed by a value and the lower and upper errors.
Definition: fields.hpp:199
If the input type is an optional, get the underying type.
Definition: fields.hpp:96
Field for a tag.
Definition: fields.hpp:116
constexpr auto const & access_value(std::optional< T > const &opt)
Definition: fields.hpp:243
type_of_t< remove_optional_t< typename Field::value_type >, Subfield... > type
Definition: fields.hpp:540
value_and_error_with_tag()
Empty constructor.
Definition: fields.hpp:183
static constexpr get_t< Field > get
Accessor to a value/error field.
Definition: fields.hpp:340
value_and_error()
Empty constructor.
Definition: fields.hpp:151
T value_type
Definition: fields.hpp:148
constexpr auto is_optional_field_v
Contain the information whether a field is optional or not.
Definition: fields.hpp:93
TagType tag
Internal tag.
Definition: fields.hpp:195
Get the overall range for a range with/without subranges.
Definition: fields.hpp:127
Utilities to handle database objects and their elements.
Definition: fields.hpp:58
std::string to_string(std::string const &v)
Convert the given object to a string.
Definition: fields.hpp:559