cpp: fix map<K, V> converter

This commit is contained in:
frsyuki 2009-06-03 22:01:27 +09:00
parent 62231983d7
commit b3846a411f
2 changed files with 6 additions and 5 deletions

View File

@ -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;

View File

@ -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