Alexandria  2.22.0
Please provide a description of the project.
Tuples.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012-2021 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef _ALEXANDRIAKERNEL_TUPLES_H
20 #define _ALEXANDRIAKERNEL_TUPLES_H
21 
23 #include <tuple>
24 #include <vector>
25 
26 namespace Euclid {
27 namespace Tuple {
28 
29 template <typename Seq>
30 struct TupleTailImpl {};
31 
32 template <std::size_t... Is>
34  template <typename T0, typename... Tn>
35  static std::tuple<Tn...> extract(std::tuple<T0, Tn...>&& knots) {
36  return std::tuple<Tn...>{std::move(std::get<1 + Is>(knots))...};
37  }
38 
39  template <typename T0, typename... Tn>
40  static std::tuple<Tn...> get(const std::tuple<T0, Tn...>& knots) {
41  return std::tuple<Tn...>{std::get<1 + Is>(knots)...};
42  }
43 };
44 
57 template <typename T0, typename... Tn>
58 static std::tuple<Tn...> Tail(std::tuple<T0, Tn...>&& tuple) {
59  return TupleTailImpl<_make_index_sequence<sizeof...(Tn)>>::extract(std::move(tuple));
60 }
61 
74 template <typename T0, typename... Tn>
75 static std::tuple<Tn...> Tail(const std::tuple<T0, Tn...>& tuple) {
76  return TupleTailImpl<_make_index_sequence<sizeof...(Tn)>>::get(tuple);
77 }
78 
79 } // namespace Tuple
80 } // namespace Euclid
81 
82 #endif // _ALEXANDRIAKERNEL_TUPLES_H
T move(T... args)
static std::tuple< Tn... > Tail(std::tuple< T0, Tn... > &&tuple)
Definition: Tuples.h:58
typename _index_sequence_helper< N >::type _make_index_sequence
static std::tuple< Tn... > get(const std::tuple< T0, Tn... > &knots)
Definition: Tuples.h:40
static std::tuple< Tn... > extract(std::tuple< T0, Tn... > &&knots)
Definition: Tuples.h:35