mirror of
https://github.com/ToruNiina/toml11.git
synced 2025-09-18 02:08:09 +08:00
fix: constructor with array-like types
This commit is contained in:
@@ -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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user