TRIQS/TRIQS 4.0.0
Researching Interacting Quantum Systems
Loading...
Searching...
No Matches
tuple_serialize.hpp
Go to the documentation of this file.
1// Copyright (c) 2013-2018 Commissariat à l'énergie atomique et aux énergies alternatives (CEA)
2// Copyright (c) 2013-2018 Centre national de la recherche scientifique (CNRS)
3// Copyright (c) 2018 Simons Foundation
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15// You may obtain a copy of the License at
16// https://www.gnu.org/licenses/gpl-3.0.txt
17//
18// Authors: Olivier Parcollet, Nils Wentzell
19
24
25#pragma once
26
27#include <tuple>
28
29namespace boost::serialization {
30
31 // Recursive helper that serializes the element at position `tuple_size - 1 - pos`.
32 template <int pos> struct tuple_serialize_impl {
33 template <typename Archive, typename T> void operator()(Archive &ar, T &t) {
34 ar &std::get<std::tuple_size_v<T> - 1 - pos>(t);
35 tuple_serialize_impl<pos - 1>()(ar, t);
36 }
37 };
38
39 // Base case of tuple_serialize_impl — serializes the last element.
40 template <> struct tuple_serialize_impl<0> {
41 template <typename Archive, typename T> void operator()(Archive &ar, T &t) { ar &std::get<std::tuple_size_v<T> - 1>(t); }
42 };
43
54 template <typename Archive, typename... Ts> void serialize(Archive &ar, std::tuple<Ts...> &t, [[maybe_unused]] const unsigned int version) {
55 tuple_serialize_impl<sizeof...(Ts) - 1>()(ar, t);
56 }
57
58} // namespace boost::serialization
const_view_type operator()() const
Make a const view of *this.
void serialize(Archive &ar, std::tuple< Ts... > &t, const unsigned int version)
Boost.Serialization entry point for std::tuple.