File tree Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Expand file tree Collapse file tree 3 files changed +19
-5
lines changed Original file line number Diff line number Diff line change @@ -112,6 +112,9 @@ class value {
112
112
const array &as_array () const ;
113
113
array &as_array ();
114
114
115
+ private:
116
+ void destroy ();
117
+
115
118
private:
116
119
struct invalid_t {};
117
120
Original file line number Diff line number Diff line change @@ -8,6 +8,13 @@ namespace json {
8
8
// Name: ~value
9
9
// ------------------------------------------------------------------------------
10
10
inline value::~value () {
11
+ destroy ();
12
+ }
13
+
14
+ // ------------------------------------------------------------------------------
15
+ // Name: ~value
16
+ // ------------------------------------------------------------------------------
17
+ inline void value::destroy () {
11
18
using std::string;
12
19
13
20
switch (type_) {
@@ -26,6 +33,8 @@ inline value::~value() {
26
33
case value::type_invalid:
27
34
break ;
28
35
}
36
+
37
+ type_ = type_invalid;
29
38
}
30
39
31
40
// ------------------------------------------------------------------------------
@@ -90,7 +99,7 @@ inline value::value(bool b) : type_(type_boolean) {
90
99
// ------------------------------------------------------------------------------
91
100
inline value::value (value &&other) : type_(other.type_) {
92
101
93
- other. type_ = type::type_invalid ;
102
+ using std::string ;
94
103
95
104
// move from the other object
96
105
switch (type_) {
@@ -109,6 +118,8 @@ inline value::value(value &&other) : type_(other.type_) {
109
118
case value::type_invalid:
110
119
break ;
111
120
}
121
+
122
+ other.destroy ();
112
123
}
113
124
114
125
// ------------------------------------------------------------------------------
Original file line number Diff line number Diff line change @@ -5,10 +5,10 @@ add_executable(example2 example2.cpp)
5
5
add_executable (example3 example3.cpp )
6
6
add_executable (example4 example4.cpp )
7
7
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 )
12
12
13
13
set_property (TARGET example1 PROPERTY CXX_STANDARD 11 )
14
14
set_property (TARGET example2 PROPERTY CXX_STANDARD 11 )
You can’t perform that action at this time.
0 commit comments