mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-17 11:05:05 +02:00
cpp: Fix convert.enum_member test (issue #50).
The patch add serialization operator for the given enum to avoid the use of a cast which leads to strict-aliasing warnings and the test to fail. Solution suggested by qehgt.
This commit is contained in:

committed by
FURUHASHI Sadayuki

parent
e511c32a36
commit
509f27eee1
@@ -34,6 +34,25 @@
|
||||
msgpack::type::make_define(__VA_ARGS__).msgpack_object(o, z); \
|
||||
}
|
||||
|
||||
// MSGPACK_ADD_ENUM must be used in the global namespace.
|
||||
#define MSGPACK_ADD_ENUM(enum) \
|
||||
namespace msgpack { \
|
||||
template <> \
|
||||
inline enum& operator>> (object o, enum& v) \
|
||||
{ \
|
||||
int tmp; \
|
||||
o >> tmp; \
|
||||
v = static_cast<enum>(tmp); \
|
||||
return v; \
|
||||
} \
|
||||
template <> \
|
||||
void operator<< (object::with_zone& o, const enum& v) \
|
||||
{ \
|
||||
int tmp = static_cast<enum>(v); \
|
||||
o << tmp; \
|
||||
} \
|
||||
}
|
||||
|
||||
namespace msgpack {
|
||||
namespace type {
|
||||
|
||||
|
Reference in New Issue
Block a user