mirror of
https://github.com/msgpack/msgpack-python.git
synced 2026-02-07 10:19:51 +00:00
cpp: add msgpack/type/tr1/unordered_{map,set}.hpp
This commit is contained in:
parent
d76093b148
commit
55cfbf378e
5 changed files with 194 additions and 2 deletions
|
|
@ -49,6 +49,31 @@ inline packer<Stream>& operator<< (packer<Stream>& o, const std::set<T>& v)
|
|||
}
|
||||
|
||||
|
||||
template <typename T>
|
||||
inline std::multiset<T>& operator>> (object o, std::multiset<T>& v)
|
||||
{
|
||||
if(o.type != type::ARRAY) { throw type_error(); }
|
||||
object* p = o.via.array.ptr + o.via.array.size;
|
||||
object* const pbegin = o.via.array.ptr;
|
||||
while(p > pbegin) {
|
||||
--p;
|
||||
v.insert(p->as<T>());
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
||||
template <typename Stream, typename T>
|
||||
inline packer<Stream>& operator<< (packer<Stream>& o, const std::multiset<T>& v)
|
||||
{
|
||||
o.pack_array(v.size());
|
||||
for(typename std::multiset<T>::const_iterator it(v.begin()), it_end(v.end());
|
||||
it != it_end; ++it) {
|
||||
o.pack(*it);
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
|
||||
} // namespace msgpack
|
||||
|
||||
#endif /* msgpack/type/set.hpp */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue