diff --git a/include/msgpack/adaptor/cpp11/unordered_map.hpp b/include/msgpack/adaptor/cpp11/unordered_map.hpp index d90ab0f4..3fe22907 100644 --- a/include/msgpack/adaptor/cpp11/unordered_map.hpp +++ b/include/msgpack/adaptor/cpp11/unordered_map.hpp @@ -42,9 +42,9 @@ struct convert> { 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::pair 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; } }; diff --git a/include/msgpack/adaptor/cpp11/unordered_set.hpp b/include/msgpack/adaptor/cpp11/unordered_set.hpp index 386e1100..b38ae339 100644 --- a/include/msgpack/adaptor/cpp11/unordered_set.hpp +++ b/include/msgpack/adaptor/cpp11/unordered_set.hpp @@ -43,7 +43,7 @@ struct convert> { --p; tmp.insert(p->as()); } - tmp.swap(v); + v = std::move(tmp); return o; } }; @@ -97,7 +97,7 @@ struct convert> { --p; tmp.insert(p->as()); } - tmp.swap(v); + v = std::move(tmp); return o; } }; diff --git a/include/msgpack/adaptor/map.hpp b/include/msgpack/adaptor/map.hpp index 4cf78219..53ee1a74 100644 --- a/include/msgpack/adaptor/map.hpp +++ b/include/msgpack/adaptor/map.hpp @@ -115,16 +115,17 @@ struct convert > { for(; p != pend; ++p) { K key; p->key.convert(key); - typename std::map::iterator it(tmp.lower_bound(key)); - if(it != tmp.end() && !(key < it->first)) { - p->val.convert(it->second); - } else { - V val; - p->val.convert(val); - tmp.insert(it, std::pair(key, val)); - } +#if __cplusplus >= 201103L + p->val.convert(tmp[std::move(key)]); +#else + p->val.convert(tmp[key]); +#endif } +#if __cplusplus >= 201103L + v = std::move(tmp); +#else tmp.swap(v); +#endif return o; } }; @@ -180,9 +181,17 @@ struct convert > { std::pair value; p->key.convert(value.first); p->val.convert(value.second); +#if __cplusplus >= 201103L + tmp.insert(std::move(value)); +#else tmp.insert(value); +#endif } +#if __cplusplus >= 201103L + v = std::move(tmp); +#else tmp.swap(v); +#endif return o; } }; diff --git a/include/msgpack/adaptor/set.hpp b/include/msgpack/adaptor/set.hpp index c44b0b82..82aa2f55 100644 --- a/include/msgpack/adaptor/set.hpp +++ b/include/msgpack/adaptor/set.hpp @@ -43,7 +43,11 @@ struct convert > { --p; tmp.insert(p->as()); } +#if __cplusplus >= 201103L + v = std::move(tmp); +#else tmp.swap(v); +#endif return o; } }; @@ -96,7 +100,11 @@ struct convert > { --p; tmp.insert(p->as()); } +#if __cplusplus >= 201103L + v = std::move(tmp); +#else tmp.swap(v); +#endif return o; } };