From f744a792e2dcfe9712d06cf596c9606b3cda607d Mon Sep 17 00:00:00 2001 From: ToruNiina Date: Mon, 17 Jun 2019 23:45:43 +0900 Subject: [PATCH] fix: constructor with array-like types --- toml/value.hpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/toml/value.hpp b/toml/value.hpp index 278c78e..71e84de 100644 --- a/toml/value.hpp +++ b/toml/value.hpp @@ -779,18 +779,17 @@ class basic_value } template::value, + std::is_convertible::value, std::nullptr_t>::type = nullptr> basic_value(std::initializer_list list) : type_(value_t::array), region_info_(std::make_shared(region_base{})) { - array_type ary; ary.reserve(list.size()); - for(auto& elem : list) {ary.emplace_back(std::move(elem));} + array_type ary(list.begin(), list.end()); assigner(this->array_, std::move(ary)); } template::value, + std::is_convertible::value, std::nullptr_t>::type = nullptr> basic_value& operator=(std::initializer_list list) { @@ -798,8 +797,7 @@ class basic_value this->type_ = value_t::array; this->region_info_ = std::make_shared(region_base{}); - array_type ary; ary.reserve(list.size()); - for(auto& elem : list) {ary.emplace_back(std::move(elem));} + array_type ary(list.begin(), list.end()); assigner(this->array_, std::move(ary)); return *this; }