Alexandria 2.31.0
SDC-CH common library for the Euclid project
Loading...
Searching...
No Matches
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
26namespace Euclid {
27namespace Tuple {
28
29template <typename Seq>
30struct TupleTailImpl {};
31
32template <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
57template <typename T0, typename... Tn>
58static std::tuple<Tn...> Tail(std::tuple<T0, Tn...>&& tuple) {
59 return TupleTailImpl<_make_index_sequence<sizeof...(Tn)>>::extract(std::move(tuple));
60}
61
74template <typename T0, typename... Tn>
75static 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