diff --git a/example/cpp03/class_intrusive.cpp b/example/cpp03/class_intrusive.cpp index e547ecb0..a770d734 100644 --- a/example/cpp03/class_intrusive.cpp +++ b/example/cpp03/class_intrusive.cpp @@ -21,10 +21,10 @@ #include #include -#if 0 // When you want to adapt map instead of array, you can enable these macro definition. -#define MSGPACK_USE_DEFINE_MAP -#define MSGPACK_USE_BOOST -#endif +// When you want to adapt map instead of array, you can enable these macro definition. +// +// #define MSGPACK_USE_DEFINE_MAP + #include @@ -100,6 +100,7 @@ int main() { } { // create object with zone my_class my("John Smith", 42); + my.a = 123; my.set_b("ABC"); my.set_c("DEF"); msgpack::zone z; diff --git a/example/cpp03/class_intrusive_map.cpp b/example/cpp03/class_intrusive_map.cpp index 5b5fef33..e3ddc707 100644 --- a/example/cpp03/class_intrusive_map.cpp +++ b/example/cpp03/class_intrusive_map.cpp @@ -28,6 +28,9 @@ class my_class { public: my_class() {} // When you want to convert from msgpack::object to my_class, // my_class should be default constractible. + // If you use C++11, you can adapt non-default constructible + // classes to msgpack::object. + // See https://github.com/msgpack/msgpack-c/wiki/v1_1_cpp_adaptor#non-default-constructible-class-support-c11-only my_class(std::string const& name, int age):name_(name), age_(age) {} friend bool operator==(my_class const& lhs, my_class const& rhs) { @@ -39,7 +42,7 @@ private: int age_; public: - MSGPACK_DEFINE(name_, age_); + MSGPACK_DEFINE_MAP(name_, age_); }; void print(std::string const& buf) {