Use std::move (C++11) in map and set adaptors where possible.

In the std::map adaptor, remove the complicated iterator/insert
code and go with the cpp11/unordered_map.hpp approach instead.
Makes the code more consistent, avoids an extra copy, and the
previous complexity was unnecessary since std::map only maps to
a single element per key, unlike std::multimap.
This commit is contained in:
Jakob Petsovits
2015-05-06 17:19:39 -04:00
committed by Jakob Petsovits
parent e8e3052d1a
commit 9725bac5c4
4 changed files with 31 additions and 14 deletions

View File

@@ -42,9 +42,9 @@ struct convert<std::unordered_map<K, V>> {
for(; p != pend; ++p) {
K key;
p->key.convert(key);
p->val.convert(tmp[key]);
p->val.convert(tmp[std::move(key)]);
}
tmp.swap(v);
v = std::move(tmp);
return o;
}
};
@@ -100,9 +100,9 @@ struct convert<std::unordered_multimap<K, V>> {
std::pair<K, V> value;
p->key.convert(value.first);
p->val.convert(value.second);
tmp.insert(value);
tmp.insert(std::move(value));
}
tmp.swap(v);
v = std::move(tmp);
return o;
}
};