From f86cdb5ca3ecb0b533552cbe12955c6f4ed2a3eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dr=2E=20Patrick=20Urbanke=20=28=E5=8A=89=E8=87=AA=E6=88=90?= =?UTF-8?q?=29?= Date: Wed, 7 May 2025 10:02:18 +0800 Subject: [PATCH] Renamed insert to insert_range to avoid ambiguous overload; fixes #420 (#430) --- include/rfl/Object.hpp | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/include/rfl/Object.hpp b/include/rfl/Object.hpp index bdd26e9e..eb888374 100644 --- a/include/rfl/Object.hpp +++ b/include/rfl/Object.hpp @@ -94,25 +94,19 @@ class Object { auto max_size() const { return data_.max_size(); } /// Inserts a new element at the end. - void insert(const value_type& _value) { - data_.push_back(_value); + template + void insert(const Args&... _values) { + (data_.push_back(_values), ...); i_ = 0; } /// Inserts a new element at the end. - void insert(value_type&& _value) { - data_.emplace_back(std::move(_value)); + template + void insert(Args&&... _values) { + (data_.emplace_back(std::move(_values)), ...); i_ = 0; } - /// Inserts several new elements at the end. - template - void insert(InputIt _first, InputIt _last) { - for (auto it = _first; it != _last; ++it) { - insert(*it); - } - } - /// Inserts a new element at the end. void insert(const std::string& _k, const T& _v) { insert(std::make_pair(_k, _v)); @@ -152,6 +146,22 @@ class Object { insert(_args...); } + /// Inserts several new elements at the end. + template + void insert_range(InputIt _first, InputIt _last) { + for (auto it = _first; it != _last; ++it) { + insert(*it); + } + } + + /// Inserts several new elements at the end. + template + void insert_range(RangeType _range) { + for (const auto& val : _range) { + insert(val); + } + } + /// Returns the element signified by the key or creates a new one. T& operator[](const std::string& _key) { const auto i = find(_key);