On 32-bit unix platforms, 0xffffffffUL is a 32-bit value so the compiler
complains about converting it to a signed value.
/home/runner/work/msgpack-c/msgpack-c/test/msgpack_cpp11.cpp:1085:20: error: constant expression evaluates to 4294967295 which cannot be narrowed to type '__time_t' (aka 'long') [-Wc++11-narrowing]
timespec val1{ 0xffffffffUL, 0 };
^~~~~~~~~~~~
/home/runner/work/msgpack-c/msgpack-c/test/msgpack_cpp11.cpp:1085:20: note: insert an explicit cast to silence this issue
timespec val1{ 0xffffffffUL, 0 };
^~~~~~~~~~~~
static_cast<__time_t>( )
/home/runner/work/msgpack-c/msgpack-c/test/msgpack_cpp11.cpp:1085:20: warning: implicit conversion changes signedness: 'unsigned long' to '__time_t' (aka 'long') [-Wsign-conversion]
timespec val1{ 0xffffffffUL, 0 };
~ ^~~~~~~~~~~~
Since we're trying to test how the maximum 32-bit value that fits in
timespec.tv_sec is handled, directly use the maximum 32-bit value for
the appropriate (un)signed type used for timespec.tv_sec.
We don't just cast to the value, as the compiler suggests, because that
would result in an extremely negative value.
msgpack::unpacked is a typedef of the msgpack::object_handle.
I recommend using msgpack::object_handle. It can be used not only
holding unpacked msgpack objects but also msgpack::objects that are
created by any types.
Replaced unpack() APIs in test codes and examples. They used to use old
APIs.
std::vector<unsigned char> and std::array<unsigned char> are mapped to BIN.
std::vector<uint8_t> and std::array<uint8_t> are mapped to BIN if uint8_t is the same type of unsigned char, otherwise mapped to ARRAY.
Added array_ref. When client wraps BIN mapped types above with array_ref as msgpack::type::array_ref<std::vector<char> >, the type is mapped to ARRAY.
enum support had been incomplete.
This fix made enum support complete.
Replaced int with auto on c++11 scoped enum.
Replaced template specializations with function overloads on operator<< and operator>> for enum.
enum can convert to object with and without zone.
When you want to adapt enum, you need to write as follows:
// NOT msgpack.hpp
enum yourenum {
elem
};
MSGPACK_ADD_ENUM(yourenum);
// msgpack.hpp should be included after MSGPACK_ADD_ENUM(...)
int main() {
msgpack::object obj(yourenum::elem);
}