diff --git a/cpp/object.hpp b/cpp/object.hpp index 13402cc3..5ed1fab0 100644 --- a/cpp/object.hpp +++ b/cpp/object.hpp @@ -81,21 +81,6 @@ inline object& operator>> (object o, object& v) template packer& operator<< (packer& o, const object& v); - - -template -inline T& operator>> (object o, T& v) -{ - v.msgpack_unpack(o); - return v; -} - -template -inline packer& operator<< (packer& o, const T& v) -{ - o << v.msgpack_pack(); - return o; -} template @@ -123,6 +108,44 @@ inline void pack_copy(packer& o, T v) pack(o, v); } + + +template +inline T& operator>> (object o, T& v) +{ + v.msgpack_unpack(o); + return v; +} + +template +inline packer& operator<< (packer& o, const T& v) +{ + o << v.msgpack_pack(); + return o; +} + + +template +class define : public Type { +public: + typedef Type msgpack_type; + typedef define define_type; + + define() {} + define(msgpack_type v) : msgpack_type(v) {} + + msgpack_type msgpack_pack() const + { + return *this; + } + + void msgpack_unpack(object o) + { + convert(static_cast(*this), o); + } +}; + + template packer& operator<< (packer& o, const object& v)