SST 15.0
Structural Simulation Toolkit
serialize_tuple.h
1// Copyright 2009-2025 NTESS. Under the terms
2// of Contract DE-NA0003525 with NTESS, the U.S.
3// Government retains certain rights in this software.
4//
5// Copyright (c) 2009-2025, NTESS
6// All rights reserved.
7//
8// This file is part of the SST software package. For license
9// information, see the LICENSE file in the top level directory of the
10// distribution.
11
12#ifndef SST_CORE_SERIALIZATION_IMPL_SERIALIZE_TUPLE_H
13#define SST_CORE_SERIALIZATION_IMPL_SERIALIZE_TUPLE_H
14
15#ifndef SST_INCLUDING_SERIALIZE_H
16#warning \
17 "The header file sst/core/serialization/impl/serialize_tuple.h should not be directly included as it is not part of the stable public API. The file is included in sst/core/serialization/serialize.h"
18#endif
19
20#include "sst/core/serialization/impl/serialize_utility.h"
21#include "sst/core/serialization/serialize.h"
22#include "sst/core/serialization/serializer.h"
23
24#include <tuple>
25
26namespace SST::Core::Serialization {
27
28// Serialize tuples and pairs
29template <typename T>
31 std::enable_if_t<is_same_type_template_v<T, std::tuple> || is_same_type_template_v<T, std::pair>>>
32{
33 void operator()(T& t, serializer& ser, ser_opt_t options)
34 {
35 // Serialize each element of tuple or pair
36 ser_opt_t opt = SerOption::is_set(options, SerOption::as_ptr_elem) ? SerOption::as_ptr : SerOption::none;
37 std::apply([&](auto&... e) { ((sst_ser_object(ser, e, opt)), ...); }, t);
38 }
39
40 SST_FRIEND_SERIALIZE();
41};
42
43} // namespace SST::Core::Serialization
44
45#endif // SST_CORE_SERIALIZATION_IMPL_SERIALIZE_TUPLE_H
Base serialize class.
Definition serialize.h:110
This class is basically a wrapper for objects to declare the order in which their members should be s...
Definition serializer.h:45