16 auto* make_node_impl_specialized(T && val, [[maybe_unused]]
value_flags flags)
18 using unwrapped_type = unwrap_node<remove_cvref<T>>;
19 static_assert(!std::is_same_v<unwrapped_type, node>);
20 static_assert(!is_node_view<unwrapped_type>);
23 if constexpr (is_one_of<unwrapped_type, array, table>)
25 return new unwrapped_type(
static_cast<T&&
>(val));
31 using native_type = native_type_of<unwrapped_type>;
32 using value_type = value<native_type>;
37 if constexpr (std::is_same_v<remove_cvref<T>, value_type>)
39 out =
new value_type{
static_cast<T&&
>(val), flags };
46 "Instantiating values from wide-character strings is only "
47 "supported on Windows with TOML_ENABLE_WINDOWS_COMPAT enabled.");
49 if constexpr (!is_losslessly_convertible_to_native<unwrapped_type>)
51 if constexpr (std::is_same_v<native_type, int64_t>)
52 static_assert(always_false<T>,
53 "Integral value initializers must be losslessly convertible to int64_t");
54 else if constexpr (std::is_same_v<native_type, double>)
55 static_assert(always_false<T>,
56 "Floating-point value initializers must be losslessly convertible to double");
60 "Value initializers must be losslessly convertible to one of the TOML value types");
63 if constexpr (is_wide_string<T>)
65#if TOML_ENABLE_WINDOWS_COMPAT
66 out =
new value_type{ narrow(
static_cast<T&&
>(val)) };
68 static_assert(always_false<T>,
"Evaluated unreachable branch!");
72 out =
new value_type{
static_cast<T&&
>(val) };
86 using unwrapped_type = unwrap_node<remove_cvref<T>>;
87 if constexpr (std::is_same_v<unwrapped_type, node> || is_node_view<unwrapped_type>)
89 if constexpr (is_node_view<unwrapped_type>)
92 return static_cast<toml::node*
>(
nullptr);
95 return static_cast<T&&
>(val).visit(
96 [flags](
auto&& concrete) {
97 return static_cast<toml::node*
>(
98 make_node_impl_specialized(
static_cast<decltype(concrete)&&
>(concrete), flags));
102 return make_node_impl_specialized(
static_cast<T&&
>(val), flags);
105 template <
typename T>
109 return make_node_impl(
static_cast<T&&
>(val.value), flags);
112 template <
typename T,
bool = (is_node<T> || is_node_view<T> || is_value<T> || can_partially_represent_native<T>)>
113 struct inserted_type_of_
115 using type = std::remove_pointer_t<decltype(make_node_impl(std::declval<T>()))>;
118 template <
typename T>
119 struct inserted_type_of_<
inserter<T>, false>
121 using type =
typename inserted_type_of_<remove_cvref<T>>::type;
124 template <
typename T>
125 struct inserted_type_of_<T, false>
130 template <
typename T>
134 return node_ptr{ make_node_impl(
static_cast<T&&
>(val), flags) };
137 template <
typename... T>
138 struct emplaced_type_of_
143 template <
typename T>
144 struct emplaced_type_of_<T>
146 using type = std::conditional_t<is_one_of<T, node, node_view<node>, node_view<const node>>,
148 typename inserted_type_of_<T>::type>;
151 template <
typename T>
152 struct emplaced_type_of_<
inserter<T>>
154 using type =
typename emplaced_type_of_<remove_cvref<T>>::type;
157 template <
typename... T>
158 using emplaced_type_of =
typename emplaced_type_of_<remove_cvref<T>...>::type;
177 template <
typename T>
enum TOML_OPEN_FLAGS_ENUM value_flags
Metadata associated with TOML values.
Definition forward_declarations.hpp:272
constexpr value_flags preserve_source_value_flags
Special #toml::value_flags constant used for array + table insert functions to specify that any value...
Definition forward_declarations.hpp:290
#define TOML_ENABLE_WINDOWS_COMPAT
Enables the use of wide strings (wchar_t, std::wstring) in various places throughout the library when...
Definition preprocessor.hpp:1074
TOML_NAMESPACE_START
Definition make_node.hpp:164
TOML_NAMESPACE_END
Definition make_node.hpp:180
#define POXY_IMPLEMENTATION_DETAIL(...)
Definition preprocessor.hpp:633
#define TOML_NODISCARD
Definition preprocessor.hpp:439
#define TOML_ATTR(...)
Definition preprocessor.hpp:316
#define TOML_IMPL_NAMESPACE_END
Definition preprocessor.hpp:1334
#define TOML_IMPL_NAMESPACE_START
Definition preprocessor.hpp:1333
Helper class for suppressing move-construction in single-argument array constructors.
Definition forward_declarations.hpp:366