|
| 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_ADAPTER_H |
| 13 | +#define SST_CORE_SERIALIZATION_IMPL_SERIALIZE_ADAPTER_H |
| 14 | + |
| 15 | +#ifndef SST_INCLUDING_SERIALIZE_H |
| 16 | +#warning \ |
| 17 | + "The header file sst/core/serialization/impl/serialize_adapter.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/serializer.h" |
| 22 | + |
| 23 | +#include <queue> |
| 24 | +#include <stack> |
| 25 | + |
| 26 | +namespace SST::Core::Serialization { |
| 27 | + |
| 28 | +// Serialize adapter classes std::stack, std::queue, std::priority_queue |
| 29 | +template <template <typename...> class T, typename... Ts> |
| 30 | +class serialize_impl< |
| 31 | + T<Ts...>, std::enable_if_t< |
| 32 | + is_same_template_v<T, std::stack> || is_same_template_v<T, std::queue> || |
| 33 | + is_same_template_v<T, std::priority_queue>>> |
| 34 | +{ |
| 35 | + struct S : T<Ts...> |
| 36 | + { |
| 37 | + using T<Ts...>::c; // access protected container |
| 38 | + }; |
| 39 | + |
| 40 | +public: |
| 41 | + void operator()(T<Ts...>& v, serializer& ser) |
| 42 | + { |
| 43 | + ser& static_cast<S&>(v).c; // serialize the underlying container |
| 44 | + } |
| 45 | +}; |
| 46 | + |
| 47 | +} // namespace SST::Core::Serialization |
| 48 | + |
| 49 | +#endif // SST_CORE_SERIALIZATION_IMPL_SERIALIZE_ADAPTER_H |
0 commit comments