@@ -186,6 +186,10 @@ template <class T> struct DefaultErrorVisitor : DefaultNullVisitor {
186
186
bool throw_error () { throw SerializationError{(static_cast <T&>(*this )).get_err_msg ()}; }
187
187
188
188
std::string get_err_msg () { return std::string{T::static_err_msg}; }
189
+
190
+ private:
191
+ DefaultErrorVisitor () = default ;
192
+ friend T; // CRTP compliance
189
193
};
190
194
191
195
struct visit_map_t ;
@@ -238,6 +242,8 @@ struct MapArrayVisitor : DefaultErrorVisitor<MapArrayVisitor<map_array>> {
238
242
assert (size == 0 );
239
243
return true ;
240
244
}
245
+
246
+ MapArrayVisitor<map_array>() = default ;
241
247
};
242
248
243
249
struct StringVisitor : DefaultErrorVisitor<StringVisitor> {
@@ -248,6 +254,8 @@ struct StringVisitor : DefaultErrorVisitor<StringVisitor> {
248
254
str = {v, size};
249
255
return true ;
250
256
}
257
+
258
+ StringVisitor () = default ;
251
259
};
252
260
253
261
struct BoolVisitor : DefaultErrorVisitor<BoolVisitor> {
@@ -258,6 +266,8 @@ struct BoolVisitor : DefaultErrorVisitor<BoolVisitor> {
258
266
value = v;
259
267
return true ;
260
268
}
269
+
270
+ BoolVisitor () = default ;
261
271
};
262
272
263
273
template <class T > struct ValueVisitor ;
@@ -282,6 +292,8 @@ template <std::integral T> struct ValueVisitor<T> : DefaultErrorVisitor<ValueVis
282
292
value = static_cast <T>(v);
283
293
return true ;
284
294
}
295
+
296
+ ValueVisitor<T>(T& v) : DefaultErrorVisitor<ValueVisitor<T>>{}, value{v} {}
285
297
};
286
298
287
299
template <> struct ValueVisitor <double > : DefaultErrorVisitor<ValueVisitor<double >> {
@@ -306,6 +318,8 @@ template <> struct ValueVisitor<double> : DefaultErrorVisitor<ValueVisitor<doubl
306
318
value = v;
307
319
return true ;
308
320
}
321
+
322
+ ValueVisitor<double >(double & v) : DefaultErrorVisitor<ValueVisitor<double >>{}, value{v} {}
309
323
};
310
324
311
325
template <> struct ValueVisitor <RealValue<asymmetric_t >> : DefaultErrorVisitor<ValueVisitor<RealValue<asymmetric_t >>> {
@@ -357,6 +371,9 @@ template <> struct ValueVisitor<RealValue<asymmetric_t>> : DefaultErrorVisitor<V
357
371
value[idx] = v;
358
372
return true ;
359
373
}
374
+
375
+ ValueVisitor<RealValue<asymmetric_t >>(RealValue<asymmetric_t >& v)
376
+ : DefaultErrorVisitor<ValueVisitor<RealValue<asymmetric_t >>>{}, value{v} {}
360
377
};
361
378
362
379
} // namespace detail
@@ -656,10 +673,9 @@ class Deserializer {
656
673
while (n_components-- != 0 ) {
657
674
component_key_ = parse_string ();
658
675
Idx const component_size = parse_map_array<visit_array_t , stay_offset>().size ;
659
- size_t const scenario_offset = offset_;
660
- // skip all the real content but check if it has map
661
- bool const has_map = parse_skip_check_map ();
662
- count_per_scenario.push_back ({component_key_, component_size, scenario_offset, has_map});
676
+ count_per_scenario.push_back ({.component = component_key_, .size = component_size, .offset = offset_});
677
+ // skip all the real content
678
+ parse_skip ();
663
679
}
664
680
component_key_ = {};
665
681
return count_per_scenario;
@@ -943,7 +959,7 @@ class Deserializer {
943
959
944
960
ctype_func_selector (attribute.ctype , [&buffer_view, &component, &attribute, this ]<class T > {
945
961
ValueVisitor<T> visitor{
946
- {}, attribute.get_attribute <T>(component.advance_ptr (buffer_view.buffer ->data , buffer_view.idx ))};
962
+ attribute.get_attribute <T>(component.advance_ptr (buffer_view.buffer ->data , buffer_view.idx ))};
947
963
msgpack::parse (data_, size_, offset_, visitor);
948
964
});
949
965
}
@@ -954,7 +970,7 @@ class Deserializer {
954
970
assert (buffer.meta_attribute != nullptr );
955
971
956
972
ctype_func_selector (buffer.meta_attribute ->ctype , [&buffer, &idx, this ]<class T > {
957
- ValueVisitor<T> visitor{{}, *(reinterpret_cast <T*>(buffer.data ) + idx)};
973
+ ValueVisitor<T> visitor{*(reinterpret_cast <T*>(buffer.data ) + idx)};
958
974
msgpack::parse (data_, size_, offset_, visitor);
959
975
});
960
976
}
0 commit comments