15 using unwrapped_type = unwrap_node<remove_cvref<T>>;
16 static_assert(!std::is_same_v<unwrapped_type, node>);
17 static_assert(!is_node_view<unwrapped_type>);
20 if constexpr (is_one_of<unwrapped_type, array, table>) {
21 return new unwrapped_type(
static_cast<T&&
>(
val));
26 using native_type = native_type_of<unwrapped_type>;
27 using value_type = value<native_type>;
32 if constexpr (std::is_same_v<remove_cvref<T>, value_type>) {
39 "Instantiating values from wide-character strings is only "
40 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
42 if constexpr (!is_losslessly_convertible_to_native<unwrapped_type>) {
43 if constexpr (std::is_same_v<native_type, int64_t>)
44 static_assert(always_false<T>,
45 "Integral value initializers must be losslessly convertible to int64_t");
46 else if constexpr (std::is_same_v<native_type, double>)
49 "Floating-point value initializers must be losslessly convertible to double");
53 "Value initializers must be losslessly convertible to one of the TOML value types");
56 if constexpr (is_wide_string<T>) {
57#if TOML_ENABLE_WINDOWS_COMPAT
60 static_assert(always_false<T>,
"Evaluated unreachable branch!");
63 out =
new value_type{
static_cast<T&&
>(
val)};
74 using unwrapped_type = unwrap_node<remove_cvref<T>>;
75 if constexpr (std::is_same_v<unwrapped_type, node> || is_node_view<unwrapped_type>) {
76 if constexpr (is_node_view<unwrapped_type>) {
77 if (!
val)
return static_cast<toml::node*
>(
nullptr);
80 return static_cast<T&&
>(
val).visit([
flags](
auto&& concrete) {
81 return static_cast<toml::node*
>(
82 make_node_impl_specialized(
static_cast<decltype(concrete)&&
>(concrete),
flags));
85 return make_node_impl_specialized(
static_cast<T&&
>(
val),
flags);
91 return make_node_impl(
static_cast<T&&
>(
val.value),
flags);
94 template <
typename T,
bool = (is_node<T> || is_node_view<T> || is_value<T> ||
95 can_partially_represent_native<T>)>
96 struct inserted_type_of_ {
97 using type = std::remove_pointer_t<decltype(make_node_impl(std::declval<T>()))>;
100 template <
typename T>
102 using type =
typename inserted_type_of_<remove_cvref<T>>::type;
105 template <
typename T>
106 struct inserted_type_of_<
T,
false> {
110 template <
typename T>
112 return node_ptr{make_node_impl(
static_cast<T&&
>(
val),
flags)};
115 template <
typename...
T>
116 struct emplaced_type_of_ {
120 template <
typename T>
121 struct emplaced_type_of_<
T> {
122 using type = std::conditional_t<is_one_of<T, node, node_view<node>, node_view<const node>>,
123 void,
typename inserted_type_of_<T>::type>;
126 template <
typename T>
128 using type =
typename emplaced_type_of_<remove_cvref<T>>::type;
131 template <
typename...
T>
132 using emplaced_type_of =
typename emplaced_type_of_<remove_cvref<T>...>::type;
151 template <
typename T>
152 using inserted_type_of =
const char * narrow(char *dst, const char *src)
enum TOML_OPEN_FLAGS_ENUM value_flags
Metadata associated with TOML values.
constexpr value_flags preserve_source_value_flags
Special #toml::value_flags constant used for array + table insert functions to specify that any value...
#define TOML_ENABLE_WINDOWS_COMPAT
Enables the use of wide strings (wchar_t, std::wstring) in various places throughout the library when...
#define POXY_IMPLEMENTATION_DETAIL(...)
#define TOML_IMPL_NAMESPACE_END
#define TOML_IMPL_NAMESPACE_START
Helper class for suppressing move-construction in single-argument array constructors.