Skip to content

Commit efc27e8

Browse files
committed
Fixed the bug that map examples don't use MSGPACK_DEFINE_MAP.
Removed MSGPACK_USE_BOOST requirement from map based serialization.
1 parent 51dd7cb commit efc27e8

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

example/cpp03/class_intrusive.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include <sstream>
2222
#include <cassert>
2323

24-
#if 0 // When you want to adapt map instead of array, you can enable these macro definition.
25-
#define MSGPACK_USE_DEFINE_MAP
26-
#define MSGPACK_USE_BOOST
27-
#endif
24+
// When you want to adapt map instead of array, you can enable these macro definition.
25+
//
26+
// #define MSGPACK_USE_DEFINE_MAP
27+
2828

2929
#include <msgpack.hpp>
3030

@@ -100,6 +100,7 @@ int main() {
100100
}
101101
{ // create object with zone
102102
my_class my("John Smith", 42);
103+
my.a = 123;
103104
my.set_b("ABC");
104105
my.set_c("DEF");
105106
msgpack::zone z;

example/cpp03/class_intrusive_map.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ class my_class {
2828
public:
2929
my_class() {} // When you want to convert from msgpack::object to my_class,
3030
// my_class should be default constractible.
31+
// If you use C++11, you can adapt non-default constructible
32+
// classes to msgpack::object.
33+
// See https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_adaptor#non-default-constructible-class-support-c11-only
3134
my_class(std::string const& name, int age):name_(name), age_(age) {}
3235

3336
friend bool operator==(my_class const& lhs, my_class const& rhs) {
@@ -39,7 +42,7 @@ class my_class {
3942
int age_;
4043

4144
public:
42-
MSGPACK_DEFINE(name_, age_);
45+
MSGPACK_DEFINE_MAP(name_, age_);
4346
};
4447

4548
void print(std::string const& buf) {

0 commit comments

Comments
 (0)