fix: constructor with array-like types

This commit is contained in:
ToruNiina
2019-06-17 23:45:43 +09:00
parent bf2dc76d5e
commit f744a792e2

View File

@@ -779,18 +779,17 @@ class basic_value
} }
template<typename T, typename std::enable_if< template<typename T, typename std::enable_if<
detail::is_convertible_to_toml_value<T, value_type>::value, std::is_convertible<T, value_type>::value,
std::nullptr_t>::type = nullptr> std::nullptr_t>::type = nullptr>
basic_value(std::initializer_list<T> list) basic_value(std::initializer_list<T> list)
: type_(value_t::array), : type_(value_t::array),
region_info_(std::make_shared<region_base>(region_base{})) region_info_(std::make_shared<region_base>(region_base{}))
{ {
array_type ary; ary.reserve(list.size()); array_type ary(list.begin(), list.end());
for(auto& elem : list) {ary.emplace_back(std::move(elem));}
assigner(this->array_, std::move(ary)); assigner(this->array_, std::move(ary));
} }
template<typename T, typename std::enable_if< template<typename T, typename std::enable_if<
detail::is_convertible_to_toml_value<T, value_type>::value, std::is_convertible<T, value_type>::value,
std::nullptr_t>::type = nullptr> std::nullptr_t>::type = nullptr>
basic_value& operator=(std::initializer_list<T> list) basic_value& operator=(std::initializer_list<T> list)
{ {
@@ -798,8 +797,7 @@ class basic_value
this->type_ = value_t::array; this->type_ = value_t::array;
this->region_info_ = std::make_shared<region_base>(region_base{}); this->region_info_ = std::make_shared<region_base>(region_base{});
array_type ary; ary.reserve(list.size()); array_type ary(list.begin(), list.end());
for(auto& elem : list) {ary.emplace_back(std::move(elem));}
assigner(this->array_, std::move(ary)); assigner(this->array_, std::move(ary));
return *this; return *this;
} }