8000 Renamed insert to insert_range to avoid ambiguous overload; fixes #420 by liuzicheng1987 · Pull Request #430 · getml/reflect-cpp · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Renamed insert to insert_range to avoid ambiguous overload; fixes #420 #430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions include/rfl/Object.hpp
B148
Original file line number Diff line number Diff line change
Expand Up @@ -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 <class... Args>
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 <class... Args>
void insert(Args&&... _values) {
(data_.emplace_back(std::move(_values)), ...);
i_ = 0;
}

/// Inserts several new elements at the end.
template <class InputIt>
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));
Expand Down Expand Up @@ -152,6 +146,22 @@ class Object {
insert(_args...);
}

/// Inserts several new elements at the end.
template <class InputIt>
void insert_range(InputIt _first, InputIt _last) {
for (auto it = _first; it != _last; ++it) {
insert(*it);
}
}

/// Inserts several new elements at the end.
template <class RangeType>
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);
Expand Down
Loading
0