@@ -11,9 +11,6 @@ namespace response {
1111
1212Value::Value (Type type /* = Type::Null*/ )
1313 : _type(type)
14- , _boolean(false )
15- , _int(0 )
16- , _float(0.0 )
1714{
1815 switch (type)
1916 {
@@ -43,37 +40,25 @@ Value::Value(Type type /*= Type::Null*/)
4340Value::Value (StringType&& value)
4441 : _type(Type::String)
4542 , _string(new StringType(std::move(value)))
46- , _boolean(false )
47- , _int(0 )
48- , _float(0.0 )
4943{
5044}
5145
5246Value::Value (BooleanType value)
5347 : _type(Type::Boolean)
54- , _boolean(false )
55- , _int(0 )
56- , _float(0.0 )
48+ , _boolean(value)
5749{
58- _boolean = value;
5950}
6051
6152Value::Value (IntType value)
6253 : _type(Type::Int)
63- , _boolean(false )
64- , _int(0 )
65- , _float(0.0 )
54+ , _int(value)
6655{
67- _int = value;
6856}
6957
7058Value::Value (FloatType value)
7159 : _type(Type::Float)
72- , _boolean(false )
73- , _int(0 )
74- , _float(0.0 )
60+ , _float(value)
7561{
76- _float = value;
7762}
7863
7964Value::Value (Value&& other) noexcept
@@ -83,28 +68,10 @@ Value::Value(Value&& other) noexcept
8368 , _list(std::move(other._list))
8469 , _string(std::move(other._string))
8570 , _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 )
8974{
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-
10875 const_cast <Type&>(other._type ) = Type::Null;
10976 other._boolean = false ;
11077 other._int = 0 ;
@@ -113,9 +80,9 @@ Value::Value(Value&& other) noexcept
11380
11481Value::Value (const Value& other)
11582 : _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 )
11986{
12087 switch (_type)
12188 {
@@ -133,18 +100,6 @@ Value::Value(const Value& other)
133100 _string.reset (new StringType (*other._string ));
134101 break ;
135102
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-
148103 case Type::Scalar:
149104 _scalar.reset (new Value (*other._scalar ));
150105 break ;
@@ -164,30 +119,12 @@ Value& Value::operator=(Value&& rhs) noexcept
164119 _list = std::move (rhs._list );
165120 _string = std::move (rhs._string );
166121 _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 ;
191128
192129 return *this ;
193130}
0 commit comments