diff --git a/include/msgpack/adaptor/int.hpp b/include/msgpack/adaptor/int.hpp index 51c0021e..8ab9bb83 100644 --- a/include/msgpack/adaptor/int.hpp +++ b/include/msgpack/adaptor/int.hpp @@ -70,30 +70,6 @@ namespace detail { return detail::convert_integer_sign::value>::convert(o); } - template - struct pack_char_sign; - - template <> - struct pack_char_sign { - template - static inline packer& pack(packer& o, char v) { - o.pack_int8(v); return o; - } - }; - - template <> - struct pack_char_sign { - template - static inline packer& pack(packer& o, char v) { - o.pack_uint8(v); return o; - } - }; - - template - static inline packer& pack_char(packer& o, char v) { - return pack_char_sign::value>::pack(o, v); - } - template struct object_char_sign; @@ -163,12 +139,12 @@ inline object const& operator>> (object const& o, unsigned long long& v) template inline packer& operator<< (packer& o, char v) - { return type::detail::pack_char(o, v); } + { o.pack_char(v); return o; } template inline packer& operator<< (packer& o, signed char v) - { o.pack_int8(v); return o; } + { o.pack_signed_char(v); return o; } template inline packer& operator<< (packer& o, signed short v) @@ -189,7 +165,7 @@ inline packer& operator<< (packer& o, signed long long v) template inline packer& operator<< (packer& o, unsigned char v) - { o.pack_uint8(v); return o; } + { o.pack_unsigned_char(v); return o; } template inline packer& operator<< (packer& o, unsigned short v) diff --git a/include/msgpack/pack.hpp b/include/msgpack/pack.hpp index 088d69a6..ed5b0a61 100644 --- a/include/msgpack/pack.hpp +++ b/include/msgpack/pack.hpp @@ -23,6 +23,7 @@ #include #include #include +#include #include "sysdep.h" @@ -283,11 +284,25 @@ inline packer& packer::pack_fix_int64(int64_t d) template inline packer& packer::pack_char(char d) -{ _pack_char(m_stream, d); return *this; } +{ +#if defined(CHAR_MIN) +#if CHAR_MIN < 0 + pack_imp_int8(d); +#else + pack_imp_uint8(d); +#endif +#else +#error CHAR_MIN is not defined +#endif + return *this; +} template inline packer& packer::pack_signed_char(signed char d) -{ _pack_signed_char(m_stream, d); return *this; } +{ + pack_imp_int8(d); + return *this; +} template inline packer& packer::pack_short(short d) @@ -424,7 +439,10 @@ inline packer& packer::pack_long_long(long long d) template inline packer& packer::pack_unsigned_char(unsigned char d) -{ _pack_unsigned_char(m_stream, d); return *this; } +{ + pack_imp_uint8(d); + return *this; +} template inline packer& packer::pack_unsigned_short(unsigned short d)