template<typename T>
toml::value class final

A TOML value.

Template parameters
T

The value's data type. Can be one of:

Base classes

class node
A TOML node.

Public types

using value_arg = std::conditional_t<std::is_same_v<T, string>, string_view, std::conditional_t<impl::is_one_of<T, double, int64_t, bool>, T, const T&>>
A type alias for 'value arguments'.
using value_type = T
The value's underlying data type.

Constructors, destructors, conversion operators

template<typename... U>
value(U && ... args) explicit noexcept(…)
Constructs a toml value.
value(value&& other) noexcept
Move constructor.
operator const T&() const & explicit noexcept
Returns a reference to the underlying value (const overload).
operator T&() & explicit noexcept
Returns a reference to the underlying value.
operator T&&() && explicit noexcept
Returns a reference to the underlying value (rvalue overload).

Public functions

auto as_boolean() const -> const value<bool>* override noexcept
Returns a const pointer to the value if the data type is a boolean.
auto as_boolean() -> value<bool>* override noexcept
Returns a pointer to the value if the data type is boolean.
auto as_date() const -> const value<date>* override noexcept
Returns a const pointer to the value if the data type is a date.
auto as_date() -> value<date>* override noexcept
Returns a pointer to the value if the data type is a date.
auto as_date_time() const -> const value<date_time>* override noexcept
Returns a const pointer to the value if the data type is a date-time.
auto as_date_time() -> value<date_time>* override noexcept
Returns a pointer to the value if the data type is date-time.
auto as_floating_point() const -> const value<double>* override noexcept
Returns a const pointer to the value if the data type is a floating-point.
auto as_floating_point() -> value<double>* override noexcept
Returns a pointer to the value if the data type is a floating-point.
auto as_integer() const -> const value<int64_t>* override noexcept
Returns a const pointer to the value if the data type is an integer.
auto as_integer() -> value<int64_t>* override noexcept
Returns a pointer to the value if the data type is an integer.
auto as_string() const -> const value<string>* override noexcept
Returns a const pointer to the value if the data type is a string.
auto as_string() -> value<string>* override noexcept
Returns a pointer to the value if the data type is a string.
auto as_time() const -> const value<time>* override noexcept
Returns a const pointer to the value if the data type is a time.
auto as_time() -> value<time>* override noexcept
Returns a pointer to the value if the data type is a time.
auto get() && -> T&& noexcept
Returns a reference to the underlying value (rvalue overload).
auto get() & -> T& noexcept
Returns a reference to the underlying value.
auto get() const & -> const T& noexcept
Returns a reference to the underlying value (const overload).
auto is_array() const -> bool override noexcept
Always returns false for value nodes.
auto is_boolean() const -> bool override noexcept
Returns true if this node is a boolean value.
auto is_date() const -> bool override noexcept
Returns true if this node is a local date value.
auto is_date_time() const -> bool override noexcept
Returns true if this node is a date-time value.
auto is_floating_point() const -> bool override noexcept
Returns true if this node is an floating-point value.
auto is_integer() const -> bool override noexcept
Returns true if this node is an integer value.
auto is_number() const -> bool override noexcept
Returns true if this node is an integer or floating-point value.
auto is_string() const -> bool override noexcept
Returns true if this node is a string value.
auto is_table() const -> bool override noexcept
Always returns false for value nodes.
auto is_time() const -> bool override noexcept
Returns true if this node is a local time value.
auto is_value() const -> bool override noexcept
Always returns true for value nodes.
auto operator*() && -> T&& noexcept
Returns a reference to the underlying value (rvalue overload).
auto operator*() & -> T& noexcept
Returns a reference to the underlying value.
auto operator*() const & -> const T& noexcept
Returns a reference to the underlying value (const overload).
auto operator=(value&& rhs) -> value& noexcept
Move-assignment operator.
auto operator=(value_arg rhs) -> value& noexcept
Value-assignment operator.
auto type() const -> node_type override noexcept
Returns the value's node type identifier.

Friends

template<typename U>
auto operator!=(const value& lhs, const value<U>& rhs) -> bool noexcept
Inequality operator.
template<typename U>
auto operator<(const value& lhs, const value<U>& rhs) -> bool noexcept
Less-than operator.
auto operator<(const value& lhs, value_arg rhs) -> bool noexcept
Value less-than operator.
auto operator<(value_arg lhs, const value& rhs) -> bool noexcept
Value less-than operator.
template<typename U>
auto operator<=(const value& lhs, const value<U>& rhs) -> bool noexcept
Less-than-or-equal-to operator.
auto operator<=(const value& lhs, value_arg rhs) -> bool noexcept
Value less-than-or-equal-to operator.
auto operator<=(value_arg lhs, const value& rhs) -> bool noexcept
Value less-than-or-equal-to operator.
template<typename U>
auto operator==(const value& lhs, const value<U>& rhs) -> bool noexcept
Equality operator.
auto operator==(const value& lhs, value_arg rhs) -> bool noexcept
Value equality operator.
template<typename U>
auto operator>(const value& lhs, const value<U>& rhs) -> bool noexcept
Greater-than operator.
auto operator>(const value& lhs, value_arg rhs) -> bool noexcept
Value greater-than operator.
auto operator>(value_arg lhs, const value& rhs) -> bool noexcept
Value greater-than operator.
template<typename U>
auto operator>=(const value& lhs, const value<U>& rhs) -> bool noexcept
Greater-than-or-equal-to operator.
auto operator>=(const value& lhs, value_arg rhs) -> bool noexcept
Value greater-than-or-equal-to operator.
auto operator>=(value_arg lhs, const value& rhs) -> bool noexcept
Value greater-than-or-equal-to operator.

Typedef documentation

template<typename T>
using toml::value<T>::value_arg = std::conditional_t<std::is_same_v<T, string>, string_view, std::conditional_t<impl::is_one_of<T, double, int64_t, bool>, T, const T&>>

A type alias for 'value arguments'.

This differs according to the value's type argument:

  • ints, floats, booleans: value_type
  • strings: string_view
  • everything else: const value_type&

Function documentation

template<typename T> template<typename... U>
toml::value<T>::value(U && ... args) explicit noexcept(…)

Constructs a toml value.

Template parameters
U Constructor argument types.
Parameters
args Arguments to forward to the internal value's constructor.

template<typename T>
node_type toml::value<T>::type() const override noexcept

Returns the value's node type identifier.

Returns

One of:

template<typename T> template<typename U>
bool operator!=(const value& lhs, const value<U>& rhs) noexcept

Inequality operator.

Parameters
lhs The LHS value.
rhs The RHS value.
Returns True if the values were not of the same type, or did not contain the same value.

template<typename T> template<typename U>
bool operator<(const value& lhs, const value<U>& rhs) noexcept

Less-than operator.

Parameters
lhs The LHS toml::value.
rhs The RHS toml::value.
Returns Same value types: lhs.get() < rhs.get()
Different value types: lhs.type() < rhs.type()

template<typename T> template<typename U>
bool operator<=(const value& lhs, const value<U>& rhs) noexcept

Less-than-or-equal-to operator.

Parameters
lhs The LHS toml::value.
rhs The RHS toml::value.
Returns Same value types: lhs.get() <= rhs.get()
Different value types: lhs.type() <= rhs.type()

template<typename T> template<typename U>
bool operator==(const value& lhs, const value<U>& rhs) noexcept

Equality operator.

Parameters
lhs The LHS value.
rhs The RHS value.
Returns True if the values were of the same type and contained the same value.

template<typename T> template<typename U>
bool operator>(const value& lhs, const value<U>& rhs) noexcept

Greater-than operator.

Parameters
lhs The LHS toml::value.
rhs The RHS toml::value.
Returns Same value types: lhs.get() > rhs.get()
Different value types: lhs.type() > rhs.type()

template<typename T> template<typename U>
bool operator>=(const value& lhs, const value<U>& rhs) noexcept

Greater-than-or-equal-to operator.

Parameters
lhs The LHS toml::value.
rhs The RHS toml::value.
Returns Same value types: lhs.get() >= rhs.get()
Different value types: lhs.type() >= rhs.type()