diff --git a/toml/toml.hpp b/toml/toml.hpp index eb47307..b0da5b2 100644 --- a/toml/toml.hpp +++ b/toml/toml.hpp @@ -296,6 +296,12 @@ class value value_traits::is_toml_type, std::nullptr_t>::type = nullptr> value& operator=(T&& v); + template::is_toml_type, std::nullptr_t>::type = nullptr> + value(std::initializer_list init); + + value(std::initializer_list> init); + value_t type() const {return type_;} template @@ -703,6 +709,27 @@ value& value::operator=(T&& v) return *this; } +template::is_toml_type, std::nullptr_t>::type> +value::value(std::initializer_list init) + : type_(toml::value_t::Array) +{ + toml::Array arr; arr.reserve(init.size()); + for(auto&& item : init) + arr.emplace_back(std::move(item)); + switch_assign::invoke(*this, std::move(arr)); +} + +inline value::value( + std::initializer_list> init) + : type_(toml::value_t::Table) +{ + toml::Table tmp; + for(auto&& item : init) + tmp.emplace(std::move(item.first), std::move(item.second)); + switch_assign::invoke(*this, std::move(tmp)); +} + template inline typename detail::toml_default_type::type const& value::cast() const