mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
add to_toml(initializer_list)
This commit is contained in:
@@ -763,7 +763,7 @@ template<typename T, toml::value_t vT = toml::detail::check_type<T>(),
|
||||
typename std::enable_if<(vT == toml::value_t::Unknown) &&
|
||||
(!toml::detail::is_map<T>::value) &&
|
||||
toml::detail::is_container<T>::value, std::nullptr_t>::type = nullptr>
|
||||
inline toml::value to_toml(T&& x)
|
||||
toml::value to_toml(T&& x)
|
||||
{
|
||||
toml::Array tmp; tmp.reserve(std::distance(std::begin(x), std::end(x)));
|
||||
for(auto iter = std::begin(x); iter != std::end(x); ++iter)
|
||||
@@ -774,7 +774,7 @@ inline toml::value to_toml(T&& x)
|
||||
template<typename T, toml::value_t vT = toml::detail::check_type<T>(),
|
||||
typename std::enable_if<(vT == toml::value_t::Unknown) &&
|
||||
toml::detail::is_map<T>::value, std::nullptr_t>::type = nullptr>
|
||||
inline toml::value to_toml(T&& x)
|
||||
toml::value to_toml(T&& x)
|
||||
{
|
||||
toml::Table tmp;
|
||||
for(auto iter = std::begin(x); iter != std::end(x); ++iter)
|
||||
@@ -782,5 +782,17 @@ inline toml::value to_toml(T&& x)
|
||||
return toml::value(std::move(tmp));
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline toml::value to_toml(std::initializer_list<T> init)
|
||||
{
|
||||
return toml::value(std::move(init));
|
||||
}
|
||||
|
||||
inline toml::value
|
||||
to_toml(std::initializer_list<std::pair<std::string, toml::value>> init)
|
||||
{
|
||||
return toml::value(std::move(init));
|
||||
}
|
||||
|
||||
}// toml
|
||||
#endif// TOML_FOR_MODERN_CPP
|
||||
|
Reference in New Issue
Block a user