Lumiera 0.pre.04
»edit your freedom«
Loading...
Searching...
No Matches
util-tuple.hpp
Go to the documentation of this file.
1/*
2 UTIL-TUPLE.hpp - helpers and convenience shortcuts for working with tuples
3
4 Copyright (C)
5 2023, Hermann Vosseler <Ichthyostega@web.de>
6
7  **Lumiera** is free software; you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by the
9  Free Software Foundation; either version 2 of the License, or (at your
10  option) any later version. See the file COPYING for further details.
11
12*/
13
14
33#ifndef UTIL_TUPLE_H
34#define UTIL_TUPLE_H
35
36
37#include <tuple>
38#include <utility>
39
40
41
42namespace util {
43
44 namespace { // recursive builder helper to unpack a sequence...
45
46 template<size_t N>
47 using cnt_ = std::integral_constant<size_t, N>;
48
49 template<class SEQ>
50 inline auto
52 {
53 return std::tuple<>{};
54 }
55
56 template<size_t N, class SEQ>
57 inline auto
59 {
60 auto prefixTuple = std::tie (*iter);
61 ++iter;
62 return std::tuple_cat (prefixTuple, _buildSeqTuple (cnt_<N-1>{}, std::forward<SEQ> (iter)));
63 }
64 }//(End) unpacking helper
65
66
78 template<size_t N, class SEQ>
79 auto
80 seqTuple (SEQ&& iter)
81 {
82 return _buildSeqTuple (cnt_<N>{}, std::forward<SEQ> (iter));
83 }
84
85
86} // namespace util
87#endif /*UTIL_TUPLE_H*/
std::integral_constant< size_t, N > cnt_
auto seqTuple(SEQ &&iter)
Unpack an iterator to build a fixed-size std::tuple of references.