Fixed a compile error caused by MSGPACK_ADD_ENUM with msgpack::packer

This commit is contained in:
Nobuyuki Kubota 2013-08-17 18:20:32 +09:00
parent 85b5e1088f
commit b5a7b5e277
2 changed files with 20 additions and 4 deletions

View File

@ -212,11 +212,20 @@ inline T& operator>> (object o, T& v)
return v;
}
namespace detail {
template <typename Stream, typename T>
struct packer_serializer {
static packer<Stream>& pack(packer<Stream>& o, const T& v) {
v.msgpack_pack(o);
return o;
}
};
}
template <typename Stream, typename T>
inline packer<Stream>& operator<< (packer<Stream>& o, const T& v)
{
v.msgpack_pack(o);
return o;
return detail::packer_serializer<Stream, T>::pack(o, v);
}
template <typename T>

View File

@ -48,8 +48,15 @@
template <> \
void operator<< (object::with_zone& o, const enum& v) \
{ \
int tmp = static_cast<enum>(v); \
o << tmp; \
o << static_cast<int>(v); \
} \
namespace detail { \
template <typename Stream> \
struct packer_serializer<Stream, enum> { \
static packer<Stream>& pack(packer<Stream>& o, const enum& v) { \
return o << static_cast<int>(v); \
} \
}; \
} \
}