Skip to content

Commit f86cdb5

Browse files
Renamed insert to insert_range to avoid ambiguous overload; fixes #420 (#430)
1 parent 41194ad commit f86cdb5

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

include/rfl/Object.hpp

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,25 +94,19 @@ class Object {
9494
auto max_size() const { return data_.max_size(); }
9595

9696
/// Inserts a new element at the end.
97-
void insert(const value_type& _value) {
98-
data_.push_back(_value);
97+
template <class... Args>
98+
void insert(const Args&... _values) {
99+
(data_.push_back(_values), ...);
99100
i_ = 0;
100101
}
101102

102103
/// Inserts a new element at the end.
103-
void insert(value_type&& _value) {
104-
data_.emplace_back(std::move(_value));
104+
template <class... Args>
105+
void insert(Args&&... _values) {
106+
(data_.emplace_back(std::move(_values)), ...);
105107
i_ = 0;
106108
}
107109

108-
/// Inserts several new elements at the end.
109-
template <class InputIt>
110-
void insert(InputIt _first, InputIt _last) {
111-
for (auto it = _first; it != _last; ++it) {
112-
insert(*it);
113-
}
114-
}
115-
116110
/// Inserts a new element at the end.
117111
void insert(const std::string& _k, const T& _v) {
118112
insert(std::make_pair(_k, _v));
@@ -152,6 +146,22 @@ class Object {
152146
insert(_args...);
153147
}
154148

149+
/// Inserts several new elements at the end.
150+
template <class InputIt>
151+
void insert_range(InputIt _first, InputIt _last) {
152+
for (auto it = _first; it != _last; ++it) {
153+
insert(*it);
154+
}
155+
}
156+
157+
/// Inserts several new elements at the end.
158+
template <class RangeType>
159+
void insert_range(RangeType _range) {
160+
for (const auto& val : _range) {
161+
insert(val);
162+
}
163+
}
164+
155165
/// Returns the element signified by the key or creates a new one.
156166
T& operator[](const std::string& _key) {
157167
const auto i = find(_key);

0 commit comments

Comments
 (0)