File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -112,6 +112,9 @@ class value {
112112 const array &as_array () const ;
113113 array &as_array ();
114114
115+ private:
116+ void destroy ();
117+
115118private:
116119 struct invalid_t {};
117120
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ namespace json {
88// Name: ~value
99// ------------------------------------------------------------------------------
1010inline value::~value () {
11+ destroy ();
12+ }
13+
14+ // ------------------------------------------------------------------------------
15+ // Name: ~value
16+ // ------------------------------------------------------------------------------
17+ inline void value::destroy () {
1118 using std::string;
1219
1320 switch (type_) {
@@ -26,6 +33,8 @@ inline value::~value() {
2633 case value::type_invalid:
2734 break ;
2835 }
36+
37+ type_ = type_invalid;
2938}
3039
3140// ------------------------------------------------------------------------------
@@ -90,7 +99,7 @@ inline value::value(bool b) : type_(type_boolean) {
9099// ------------------------------------------------------------------------------
91100inline value::value (value &&other) : type_(other.type_) {
92101
93- other. type_ = type::type_invalid ;
102+ using std::string ;
94103
95104 // move from the other object
96105 switch (type_) {
@@ -109,6 +118,8 @@ inline value::value(value &&other) : type_(other.type_) {
109118 case value::type_invalid:
110119 break ;
111120 }
121+
122+ other.destroy ();
112123}
113124
114125// ------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ add_executable(example2 example2.cpp)
55add_executable (example3 example3.cpp )
66add_executable (example4 example4.cpp )
77
8- target_link_libraries (example1 LINK_PUBLIC cpp-json )
9- target_link_libraries (example2 LINK_PUBLIC cpp-json )
10- target_link_libraries (example3 LINK_PUBLIC cpp-json )
11- target_link_libraries (example4 LINK_PUBLIC cpp-json )
8+ target_link_libraries (example1 PUBLIC cpp-json )
9+ target_link_libraries (example2 PUBLIC cpp-json )
10+ target_link_libraries (example3 PUBLIC cpp-json )
11+ target_link_libraries (example4 PUBLIC cpp-json )
1212
1313set_property (TARGET example1 PROPERTY CXX_STANDARD 11 )
1414set_property (TARGET example2 PROPERTY CXX_STANDARD 11 )
You can’t perform that action at this time.
0 commit comments