From b5a7b5e277db7d52e9084c6805b1e32e5fb0044c Mon Sep 17 00:00:00 2001 From: Nobuyuki Kubota Date: Sat, 17 Aug 2013 18:20:32 +0900 Subject: [PATCH] Fixed a compile error caused by MSGPACK_ADD_ENUM with msgpack::packer --- src/msgpack/object.hpp | 13 +++++++++++-- src/msgpack/type/define.hpp.erb | 11 +++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) 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); \ + } \ + }; \ } \ }