mirror of
https://codeberg.org/DawnMagnet/reflect-cpp
synced 2026-12-03 00:26:19 +08:00
This commit is contained in:
+22
-12
@@ -94,25 +94,19 @@ class Object {
|
|||||||
auto max_size() const { return data_.max_size(); }
|
auto max_size() const { return data_.max_size(); }
|
||||||
|
|
||||||
/// Inserts a new element at the end.
|
/// Inserts a new element at the end.
|
||||||
void insert(const value_type& _value) {
|
template <class... Args>
|
||||||
data_.push_back(_value);
|
void insert(const Args&... _values) {
|
||||||
|
(data_.push_back(_values), ...);
|
||||||
i_ = 0;
|
i_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Inserts a new element at the end.
|
/// Inserts a new element at the end.
|
||||||
void insert(value_type&& _value) {
|
template <class... Args>
|
||||||
data_.emplace_back(std::move(_value));
|
void insert(Args&&... _values) {
|
||||||
|
(data_.emplace_back(std::move(_values)), ...);
|
||||||
i_ = 0;
|
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.
|
/// Inserts a new element at the end.
|
||||||
void insert(const std::string& _k, const T& _v) {
|
void insert(const std::string& _k, const T& _v) {
|
||||||
insert(std::make_pair(_k, _v));
|
insert(std::make_pair(_k, _v));
|
||||||
@@ -152,6 +146,22 @@ class Object {
|
|||||||
insert(_args...);
|
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.
|
/// Returns the element signified by the key or creates a new one.
|
||||||
T& operator[](const std::string& _key) {
|
T& operator[](const std::string& _key) {
|
||||||
const auto i = find(_key);
|
const auto i = find(_key);
|
||||||
|
|||||||
Reference in New Issue
Block a user