Update toml library

This commit is contained in:
daleclack 2023-05-07 11:06:05 +08:00
parent 5244ae0adf
commit 4c3c388cbd
1 changed files with 34 additions and 21 deletions

View File

@ -4636,7 +4636,7 @@ TOML_IMPL_NAMESPACE_START
{ {
template <typename T> template <typename T>
TOML_NODISCARD TOML_NODISCARD
static std::string make(T&& arg) noexcept static std::string make(T&& arg)
{ {
using arg_type = std::decay_t<T>; using arg_type = std::decay_t<T>;
#if TOML_HAS_CHAR8 #if TOML_HAS_CHAR8
@ -4721,6 +4721,14 @@ TOML_IMPL_NAMESPACE_START
} }
return { static_cast<T>(val) }; return { static_cast<T>(val) };
} }
template <typename...>
struct value_variadic_ctor_allowed : std::true_type
{};
template <typename T, typename... Args>
struct value_variadic_ctor_allowed<value<T>, value<T>, Args...> : std::false_type
{};
} }
TOML_IMPL_NAMESPACE_END; TOML_IMPL_NAMESPACE_END;
@ -4759,7 +4767,9 @@ TOML_NAMESPACE_START
std::string_view, std::string_view,
std::conditional_t<impl::is_one_of<value_type, double, int64_t, bool>, value_type, const value_type&>>); std::conditional_t<impl::is_one_of<value_type, double, int64_t, bool>, value_type, const value_type&>>);
template <typename... Args> TOML_HIDDEN_CONSTRAINT(
(impl::value_variadic_ctor_allowed<value<ValueType>, impl::remove_cvref<Args>...>::value),
typename... Args)
TOML_NODISCARD_CTOR TOML_NODISCARD_CTOR
explicit value(Args&&... args) noexcept(noexcept(value_type( explicit value(Args&&... args) noexcept(noexcept(value_type(
impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...)))) impl::native_value_maker<value_type, std::decay_t<Args>...>::make(static_cast<Args&&>(args)...))))
@ -4796,7 +4806,7 @@ TOML_NAMESPACE_START
value(value&& other) noexcept // value(value&& other) noexcept //
: node(std::move(other)), : node(std::move(other)),
val_{ std::move(other.val_) }, val_{ std::move(other.val_) },
flags_{ other.flags_ } flags_{ std::exchange(other.flags_, value_flags{}) }
{ {
#if TOML_LIFETIME_HOOKS #if TOML_LIFETIME_HOOKS
TOML_VALUE_CREATED; TOML_VALUE_CREATED;
@ -4812,6 +4822,7 @@ TOML_NAMESPACE_START
#if TOML_LIFETIME_HOOKS #if TOML_LIFETIME_HOOKS
TOML_VALUE_CREATED; TOML_VALUE_CREATED;
#endif #endif
other.flags_ = {};
} }
value& operator=(const value& rhs) noexcept value& operator=(const value& rhs) noexcept
@ -4828,7 +4839,7 @@ TOML_NAMESPACE_START
{ {
node::operator=(std::move(rhs)); node::operator=(std::move(rhs));
val_ = std::move(rhs.val_); val_ = std::move(rhs.val_);
flags_ = rhs.flags_; flags_ = std::exchange(rhs.flags_, value_flags{});
} }
return *this; return *this;
} }
@ -5316,6 +5327,8 @@ TOML_NAMESPACE_START
template <typename T> template <typename T>
value(T) -> value<impl::native_type_of<impl::remove_cvref<T>>>; value(T) -> value<impl::native_type_of<impl::remove_cvref<T>>>;
template <typename T>
value(T, value_flags) -> value<impl::native_type_of<impl::remove_cvref<T>>>;
template <typename T> template <typename T>
TOML_NODISCARD TOML_NODISCARD
@ -5649,7 +5662,7 @@ TOML_IMPL_NAMESPACE_START
// copy/move ctor // copy/move ctor
if constexpr (std::is_same_v<remove_cvref<T>, value_type>) if constexpr (std::is_same_v<remove_cvref<T>, value_type>)
{ {
out = new value_type{ static_cast<T&&>(val) }; out = new value_type{ static_cast<T&&>(val), flags };
} }
// creating from raw value // creating from raw value
@ -5683,10 +5696,10 @@ TOML_IMPL_NAMESPACE_START
} }
else else
out = new value_type{ static_cast<T&&>(val) }; out = new value_type{ static_cast<T&&>(val) };
}
if (flags != preserve_source_value_flags) if (flags != preserve_source_value_flags)
out->flags(flags); out->flags(flags);
}
return out; return out;
} }