mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-03-22 00:19:19 +01:00
cpp: fix map<K, V> converter
This commit is contained in:
parent
b0062a7f6f
commit
8617213149
@ -80,13 +80,13 @@ inline std::map<K, V> operator>> (object o, std::map<K, V>& v)
|
|||||||
for(; p != pend; ++p) {
|
for(; p != pend; ++p) {
|
||||||
K key;
|
K key;
|
||||||
p->key.convert(&key);
|
p->key.convert(&key);
|
||||||
typename std::map<K,V>::iterator it(v.find(key));
|
typename std::map<K,V>::iterator it(v.lower_bound(key));
|
||||||
if(it != v.end()) {
|
if(it != v.end() && !(key < it->first)) {
|
||||||
|
p->val.convert(&it->second);
|
||||||
|
} else {
|
||||||
V val;
|
V val;
|
||||||
p->val.convert(&val);
|
p->val.convert(&val);
|
||||||
it->insert( std::pair<K,V>(key, val) );
|
v.insert(it, std::pair<K,V>(key, val));
|
||||||
} else {
|
|
||||||
p->val.convert(&it->second);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return v;
|
return v;
|
||||||
|
@ -219,6 +219,7 @@ class MessagePackTestFormat < Test::Unit::TestCase
|
|||||||
|
|
||||||
def match(obj, buf)
|
def match(obj, buf)
|
||||||
assert_equal(obj.to_msgpack, buf)
|
assert_equal(obj.to_msgpack, buf)
|
||||||
|
assert_equal(MessagePack::unpack(buf), obj)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user