136 using value_type =
typename remove_const_key<typename OBJ::value_type>::type;
138 void operator()(OBJ& obj,
serializer& ser, ser_opt_t options)
140 switch (
const auto mode = ser.mode() ) {
141 case serializer::SIZER:
142 case serializer::PACK:
144 size_t size = get_size(obj);
146 if ( mode == serializer::PACK )
151 if constexpr ( is_vector_bool_v<OBJ> ) {
159 SerOption::is_set(options, SerOption::as_ptr_elem) ? SerOption::as_ptr : SerOption::none;
161 for (
auto& e : obj )
162 SST_SER(
const_cast<value_type&
>(
reinterpret_cast<const value_type&
>(e)), opts);
167 case serializer::UNPACK:
173 ser_opt_t opts = SerOption::is_set(options, SerOption::as_ptr_elem) ? SerOption::as_ptr : SerOption::none;
178 if constexpr ( is_same_type_template_v<OBJ, std::vector> ) obj.reserve(size);
180 if constexpr ( is_same_type_template_v<OBJ, std::forward_list> ) {
181 auto last = obj.before_begin();
182 for (
size_t i = 0; i < size; ++i ) {
183 last = obj.emplace_after(last);
185 SST_SER(value, opts);
189 for (
size_t i = 0; i < size; ++i ) {
191 is_same_type_template_v<OBJ, std::map> ||
192 is_same_type_template_v<OBJ, std::unordered_map> ) {
193 typename OBJ::key_type key {};
195 auto& value = obj[std::move(key)];
196 SST_SER(value, opts);
199 is_same_type_template_v<OBJ, std::multimap> ||
200 is_same_type_template_v<OBJ, std::unordered_multimap> ) {
201 typename OBJ::key_type key {};
203 auto& value = obj.emplace(std::move(key),
typename OBJ::mapped_type {})->second;
204 SST_SER(value, opts);
207 is_same_type_template_v<OBJ, std::set> ||
208 is_same_type_template_v<OBJ, std::unordered_set> ||
209 is_same_type_template_v<OBJ, std::multiset> ||
210 is_same_type_template_v<OBJ, std::unordered_multiset> ) {
211 typename OBJ::key_type key {};
213 opts = SerOption::none;
215 obj.emplace(std::move(key));
217 else if constexpr ( is_vector_bool_v<OBJ> ) {
219 opts = SerOption::none;
220 SST_SER(value, opts);
221 obj.push_back(value);
224 auto& value = obj.emplace_back();
225 SST_SER(value, opts);
233 case serializer::MAP:
235 using SST::Core::to_string;
236 const std::string& name = ser.getMapName();
238 ser.mapper().map_hierarchy_start(name, obj_map);
240 if constexpr ( is_vector_bool_v<OBJ> ) {
244 sst_ser_object(ser, e, SerOption::none, to_string(i++).c_str());
246 else if constexpr ( is_simple_map_v<OBJ> ) {
248 for (
auto& [key, value] : obj )
249 sst_ser_object(ser, value, SerOption::none, to_string(key).c_str());
257 for (
auto& e : obj )
259 ser,
const_cast<value_type&
>(
reinterpret_cast<const value_type&
>(e)), SerOption::none,
260 to_string(i++).c_str());
262 ser.mapper().map_hierarchy_end();
268 SST_FRIEND_SERIALIZE();