mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-18 12:34:15 +01:00
cpp: fix map<K, V> converter
This commit is contained in:
parent
62231983d7
commit
b3846a411f
@ -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;
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user