diff --git a/src/msgpack/object.hpp b/src/msgpack/object.hpp index 97c8d4aa..76fe4cae 100644 --- a/src/msgpack/object.hpp +++ b/src/msgpack/object.hpp @@ -212,11 +212,20 @@ inline T& operator>> (object o, T& v) return v; } +namespace detail { +template +struct packer_serializer { + static packer& pack(packer& o, const T& v) { + v.msgpack_pack(o); + return o; + } +}; +} + template inline packer& operator<< (packer& o, const T& v) { - v.msgpack_pack(o); - return o; + return detail::packer_serializer::pack(o, v); } template diff --git a/src/msgpack/type/define.hpp.erb b/src/msgpack/type/define.hpp.erb index c8a86512..0e0cea04 100644 --- a/src/msgpack/type/define.hpp.erb +++ b/src/msgpack/type/define.hpp.erb @@ -48,8 +48,15 @@ template <> \ void operator<< (object::with_zone& o, const enum& v) \ { \ - int tmp = static_cast(v); \ - o << tmp; \ + o << static_cast(v); \ + } \ + namespace detail { \ + template \ + struct packer_serializer { \ + static packer& pack(packer& o, const enum& v) { \ + return o << static_cast(v); \ + } \ + }; \ } \ }