@@ -11,9 +11,6 @@ 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 )
17
14
{
18
15
switch (type)
19
16
{
@@ -43,37 +40,25 @@ Value::Value(Type type /*= Type::Null*/)
43
40
Value::Value (StringType&& value)
44
41
: _type(Type::String)
45
42
, _string(new StringType(std::move(value)))
46
- , _boolean(false )
47
- , _int(0 )
48
- , _float(0.0 )
49
43
{
50
44
}
51
45
52
46
Value::Value (BooleanType value)
53
47
: _type(Type::Boolean)
54
- , _boolean(false )
55
- , _int(0 )
56
- , _float(0.0 )
48
+ , _boolean(value)
57
49
{
58
- _boolean = value;
59
50
}
60
51
61
52
Value::Value (IntType value)
62
53
: _type(Type::Int)
63
- , _boolean(false )
64
- , _int(0 )
65
- , _float(0.0 )
54
+ , _int(value)
66
55
{
67
- _int = value;
68
56
}
69
57
70
58
Value::Value (FloatType value)
71
59
: _type(Type::Float)
72
- , _boolean(false )
73
- , _int(0 )
74
- , _float(0.0 )
60
+ , _float(value)
75
61
{
76
- _float = value;
77
62
}
78
63
79
64
Value::Value (Value&& other) noexcept
@@ -83,28 +68,10 @@ Value::Value(Value&& other) noexcept
83
68
, _list(std::move(other._list))
84
69
, _string(std::move(other._string))
85
70
, _scalar(std::move(other._scalar))
86
- , _boolean(false )
87
- , _int(0 )
88
- , _float(0.0 )
71
+ , _boolean(other._boolean )
72
+ , _int(other._int )
73
+ , _float(other._float )
89
74
{
90
- switch (_type)
91
- {
92
- case Type::Boolean:
93
- _boolean = other._boolean ;
94
- break ;
95
-
96
- case Type::Int:
97
- _int = other._int ;
98
- break ;
99
-
100
- case Type::Float:
101
- _float = other._float ;
102
- break ;
103
-
104
- default :
105
- break ;
106
- }
107
-
108
75
const_cast <Type&>(other._type ) = Type::Null;
109
76
other._boolean = false ;
110
77
other._int = 0 ;
@@ -113,9 +80,9 @@ Value::Value(Value&& other) noexcept
113
80
114
81
Value::Value (const Value& other)
115
82
: _type(other._type)
116
- , _boolean(false )
117
- , _int(0 )
118
- , _float(0.0 )
83
+ , _boolean(other._boolean )
84
+ , _int(other._int )
85
+ , _float(other._float )
119
86
{
120
87
switch (_type)
121
88
{
@@ -133,18 +100,6 @@ Value::Value(const Value& other)
133
100
_string.reset (new StringType (*other._string ));
134
101
break ;
135
102
136
- case Type::Boolean:
137
- _boolean = other._boolean ;
138
- break ;
139
-
140
- case Type::Int:
141
- _int = other._int ;
142
- break ;
143
-
144
- case Type::Float:
145
- _float = other._float ;
146
- break ;
147
-
148
103
case Type::Scalar:
149
104
_scalar.reset (new Value (*other._scalar ));
150
105
break ;
@@ -164,30 +119,12 @@ Value& Value::operator=(Value&& rhs) noexcept
164
119
_list = std::move (rhs._list );
165
120
_string = std::move (rhs._string );
166
121
_scalar = std::move (rhs._scalar );
167
- _boolean = false ;
168
- _int = 0 ;
169
- _float = 0.0 ;
170
-
171
- switch (_type)
172
- {
173
- case Type::Boolean:
174
- _boolean = rhs._boolean ;
175
- rhs._boolean = false ;
176
- break ;
177
-
178
- case Type::Int:
179
- _int = rhs._int ;
180
- rhs._int = 0 ;
181
- break ;
182
-
183
- case Type::Float:
184
- _float = rhs._float ;
185
- rhs._float = 0.0 ;
186
- break ;
187
-
188
- default :
189
- break ;
190
- }
122
+ _boolean = rhs._boolean ;
123
+ rhs._boolean = false ;
124
+ _int = rhs._int ;
125
+ rhs._int = 0 ;
126
+ _float = rhs._float ;
127
+ rhs._float = 0.0 ;
191
128
192
129
return *this ;
193
130
}
0 commit comments