@@ -11,6 +11,9 @@ namespace response {
11
11
12
12
Value::Value (Type type /* = Type::Null*/ )
13
13
: _type(type)
14
+ , _boolean(false )
15
+ , _int(0 )
16
+ , _float(0.0 )
14
17
{
15
18
switch (type)
16
19
{
@@ -28,18 +31,6 @@ Value::Value(Type type /*= Type::Null*/)
28
31
_string.reset (new StringType ());
29
32
break ;
30
33
31
- case Type::Boolean:
32
- _boolean = false ;
33
- break ;
34
-
35
- case Type::Int:
36
- _int = 0 ;
37
- break ;
38
-
39
- case Type::Float:
40
- _float = 0 ;
41
- break ;
42
-
43
34
case Type::Scalar:
44
35
_scalar.reset (new Value ());
45
36
break ;
@@ -52,34 +43,49 @@ Value::Value(Type type /*= Type::Null*/)
52
43
Value::Value (StringType&& value)
53
44
: _type(Type::String)
54
45
, _string(new StringType(std::move(value)))
46
+ , _boolean(false )
47
+ , _int(0 )
48
+ , _float(0.0 )
55
49
{
56
50
}
57
51
58
52
Value::Value (BooleanType value)
59
53
: _type(Type::Boolean)
60
- , _boolean(value)
54
+ , _boolean(false )
55
+ , _int(0 )
56
+ , _float(0.0 )
61
57
{
58
+ _boolean = value;
62
59
}
63
60
64
61
Value::Value (IntType value)
65
62
: _type(Type::Int)
66
- , _int(value)
63
+ , _boolean(false )
64
+ , _int(0 )
65
+ , _float(0.0 )
67
66
{
67
+ _int = value;
68
68
}
69
69
70
70
Value::Value (FloatType value)
71
71
: _type(Type::Float)
72
- , _float(value)
72
+ , _boolean(false )
73
+ , _int(0 )
74
+ , _float(0.0 )
73
75
{
76
+ _float = value;
74
77
}
75
78
76
- Value::Value (Value&& other)
79
+ Value::Value (Value&& other) noexcept
77
80
: _type(other._type)
78
81
, _members(std::move(other._members))
79
82
, _map(std::move(other._map))
80
83
, _list(std::move(other._list))
81
84
, _string(std::move(other._string))
82
85
, _scalar(std::move(other._scalar))
86
+ , _boolean(false )
87
+ , _int(0 )
88
+ , _float(0.0 )
83
89
{
84
90
switch (_type)
85
91
{
@@ -98,10 +104,18 @@ Value::Value(Value&& other)
98
104
default :
99
105
break ;
100
106
}
107
+
108
+ const_cast <Type&>(other._type ) = Type::Null;
109
+ other._boolean = false ;
110
+ other._int = 0 ;
111
+ other._float = 0.0 ;
101
112
}
102
113
103
114
Value::Value (const Value& other)
104
115
: _type(other._type)
116
+ , _boolean(false )
117
+ , _int(0 )
118
+ , _float(0.0 )
105
119
{
106
120
switch (_type)
107
121
{
@@ -140,7 +154,7 @@ Value::Value(const Value& other)
140
154
}
141
155
}
142
156
143
- Value& Value::operator =(Value&& rhs)
157
+ Value& Value::operator =(Value&& rhs) noexcept
144
158
{
145
159
const_cast <Type&>(_type) = rhs._type ;
146
160
const_cast <Type&>(rhs._type ) = Type::Null;
@@ -150,19 +164,25 @@ Value& Value::operator=(Value&& rhs)
150
164
_list = std::move (rhs._list );
151
165
_string = std::move (rhs._string );
152
166
_scalar = std::move (rhs._scalar );
167
+ _boolean = false ;
168
+ _int = 0 ;
169
+ _float = 0.0 ;
153
170
154
171
switch (_type)
155
172
{
156
173
case Type::Boolean:
157
174
_boolean = rhs._boolean ;
175
+ rhs._boolean = false ;
158
176
break ;
159
177
160
178
case Type::Int:
161
179
_int = rhs._int ;
180
+ rhs._int = 0 ;
162
181
break ;
163
182
164
183
case Type::Float:
165
184
_float = rhs._float ;
185
+ rhs._float = 0.0 ;
166
186
break ;
167
187
168
188
default :
0 commit comments