template<class T> MsgpackInArchive & operator&(std::list<T> & o) { size_t size; upk.next(&msg); msg.get().convert(&size); for (size_t i = 0; i < size; ++i) { o.push_back(T()); *this & o.back(); } return *this; }
template<class T> MsgpackInArchive & operator&(std::shared_ptr<T> & o) { bool valid; upk.next(&msg); msg.get().convert(&valid); if (valid) { o.reset(new T()); *this & *o; } else o.reset(); return *this; }
template<class T> MsgpackInArchive & operator&(T & o) { upk.next(&msg); msg.get().convert(&o); return *this; }
{ printf("\nMsgPack write speed:\n"); const std::vector<float> src(NUM_VALS, 3.14f); printf("Writing... "); time_n(16, [&]() { msgpack::sbuffer buffer; // simple buffer //msgpack::pack(&buffer, src); for (auto f : src) { msgpack::pack(&buffer, f); } }); #if 0 msgpack::unpacked msg; msgpack_object mobj; printf("Parsing... "); time([&]() { msgpack::unpack(&msg, buffer.data(), buffer.size()); mobj = msg.get(); }); msgpack::object obj = mobj; printf("Copying... "); time([&]() { obj.convert(&dst); REQUIRE( dst[1] == 3.14f ); }); #endif