diff options
-rw-r--r-- | cpp/type/map.hpp | 10 | ||||
-rw-r--r-- | ruby/test_case.rb | 1 |
2 files changed, 6 insertions, 5 deletions
diff --git a/cpp/type/map.hpp b/cpp/type/map.hpp index c136d53..552de57 100644 --- a/cpp/type/map.hpp +++ b/cpp/type/map.hpp @@ -80,13 +80,13 @@ inline std::map<K, V> operator>> (object o, std::map<K, V>& v) for(; p != pend; ++p) { K key; p->key.convert(&key); - typename std::map<K,V>::iterator it(v.find(key)); - if(it != v.end()) { + typename std::map<K,V>::iterator it(v.lower_bound(key)); + if(it != v.end() && !(key < it->first)) { + p->val.convert(&it->second); + } else { V val; p->val.convert(&val); - it->insert( std::pair<K,V>(key, val) ); - } else { - p->val.convert(&it->second); + v.insert(it, std::pair<K,V>(key, val)); } } return v; diff --git a/ruby/test_case.rb b/ruby/test_case.rb index 2d897df..4fbcea3 100644 --- a/ruby/test_case.rb +++ b/ruby/test_case.rb @@ -219,6 +219,7 @@ class MessagePackTestFormat < Test::Unit::TestCase def match(obj, buf) assert_equal(obj.to_msgpack, buf) + assert_equal(MessagePack::unpack(buf), obj) end end |