diff options
| author | 2021-04-18 04:37:51 +0100 | |
|---|---|---|
| committer | 2021-04-18 04:58:28 +0100 | |
| commit | 569324feeecea939854e45bbd44495b849fcfd59 (patch) | |
| tree | 38008340f746112ab17ebb8368f090aeac10aabd /include | |
| parent | Make the reason parameter to PartUser const. (diff) | |
Migrate collections from insert to emplace.
Diffstat (limited to 'include')
| -rw-r--r-- | include/clientprotocol.h | 2 | ||||
| -rw-r--r-- | include/flat_map.h | 26 | ||||
| -rw-r--r-- | include/logger.h | 2 |
3 files changed, 27 insertions, 3 deletions
diff --git a/include/clientprotocol.h b/include/clientprotocol.h index 9bb8f47e2..c5b880d4e 100644 --- a/include/clientprotocol.h +++ b/include/clientprotocol.h @@ -415,7 +415,7 @@ class ClientProtocol::Message : public ClientProtocol::MessageSource */ void AddTag(const std::string& tagname, MessageTagProvider* tagprov, const std::string& val, void* tagdata = NULL) { - tags.insert(std::make_pair(tagname, MessageTagData(tagprov, val, tagdata))); + tags.emplace(tagname, MessageTagData(tagprov, val, tagdata)); } /** Add all tags in a TagMap to the tags in this message. Existing tags will not be overwritten. diff --git a/include/flat_map.h b/include/flat_map.h index ffa313bef..f735ca669 100644 --- a/include/flat_map.h +++ b/include/flat_map.h @@ -233,6 +233,12 @@ class flat_set : public detail::flat_map_base<T, Comp, T, ElementComp> flat_set& operator=(const flat_set& other) = default; + template <typename... Args> + std::pair<iterator, bool> emplace(Args&&... args) + { + return insert(value_type(std::forward<Args>(args)...)); + } + std::pair<iterator, bool> insert(const value_type& x) { return this->insert_single(x); @@ -281,6 +287,12 @@ class flat_multiset : public detail::flat_map_base<T, Comp, T, ElementComp> flat_multiset& operator=(const flat_multiset& other) = default; + template <typename... Args> + iterator emplace(Args&&... args) + { + return insert(value_type(std::forward<Args>(args)...)); + } + iterator insert(const value_type& x) { return this->insert_multi(x); @@ -332,6 +344,12 @@ class flat_map : public detail::flat_map_base<std::pair<T, U>, Comp, T, detail:: flat_map& operator=(const flat_map& other) = default; + template <typename... Args> + std::pair<iterator, bool> emplace(Args&&... args) + { + return insert(value_type(std::forward<Args>(args)...)); + } + std::pair<iterator, bool> insert(const value_type& x) { return this->insert_single(x); @@ -351,7 +369,7 @@ class flat_map : public detail::flat_map_base<std::pair<T, U>, Comp, T, detail:: mapped_type& operator[](const key_type& x) { - return insert(std::make_pair(x, mapped_type())).first->second; + return insert(value_type(x, mapped_type())).first->second; } value_compare value_comp() const @@ -392,6 +410,12 @@ class flat_multimap : public detail::flat_map_base<std::pair<T, U>, Comp, T, det flat_multimap& operator=(const flat_multimap& other) = default; + template <typename... Args> + iterator emplace(Args&&... args) + { + return insert(value_type(std::forward<Args>(args)...)); + } + iterator insert(const value_type& x) { return this->insert_multi(x); diff --git a/include/logger.h b/include/logger.h index 2327fc13d..751ff3ed7 100644 --- a/include/logger.h +++ b/include/logger.h @@ -151,7 +151,7 @@ class CoreExport LogManager FileLogMap::iterator i = FileLogs.find(fw); if (i == FileLogs.end()) { - FileLogs.insert(std::make_pair(fw, 1)); + FileLogs.emplace(fw, 1); } else { |
