Blaze 3.9
IntegerSequence.h
Go to the documentation of this file.
1//=================================================================================================
33//=================================================================================================
34
35#ifndef _BLAZE_UTIL_INTEGERSEQUENCE_H_
36#define _BLAZE_UTIL_INTEGERSEQUENCE_H_
37
38
39//*************************************************************************************************
40// Includes
41//*************************************************************************************************
42
43#include <utility>
45
46
47namespace blaze {
48
49//=================================================================================================
50//
51// TYPE DEFINITIONS
52//
53//=================================================================================================
54
55//*************************************************************************************************
60using std::integer_sequence;
61//*************************************************************************************************
62
63
64//*************************************************************************************************
69using std::index_sequence;
70//*************************************************************************************************
71
72
73//*************************************************************************************************
78using std::make_integer_sequence;
79//*************************************************************************************************
80
81
82//*************************************************************************************************
87using std::make_index_sequence;
88//*************************************************************************************************
89
90
91
92
93//=================================================================================================
94//
95// GLOBAL OPERATORS
96//
97//=================================================================================================
98
99//*************************************************************************************************
107template< size_t... I1s, size_t... I2s > //
108constexpr bool operator==( index_sequence<I1s...> lhs, index_sequence<I2s...> rhs ) noexcept
109{
110 MAYBE_UNUSED( lhs, rhs );
111
112 return false;
113}
114//*************************************************************************************************
115
116
117//*************************************************************************************************
126template< size_t... I1s > //
127constexpr bool operator==( index_sequence<I1s...> lhs, index_sequence<I1s...> rhs ) noexcept
128{
129 MAYBE_UNUSED( lhs, rhs );
130
131 return true;
132}
134//*************************************************************************************************
135
136
137//*************************************************************************************************
145template< size_t... I1s, size_t... I2s >
146constexpr bool operator!=( index_sequence<I1s...> lhs, index_sequence<I2s...> rhs ) noexcept
147{
148 MAYBE_UNUSED( lhs, rhs );
149
150 return !( lhs == rhs );
151}
152//*************************************************************************************************
153
154
155
156
157//=================================================================================================
158//
159// UTILITY FUNCTIONS
160//
161//=================================================================================================
162
163//*************************************************************************************************
171template< size_t Offset // The offset for the shift operation
172 , size_t... Is > // The sequence of indices
173constexpr decltype(auto) shift( std::index_sequence<Is...> sequence )
174{
175 MAYBE_UNUSED( sequence );
176
177 return std::index_sequence< ( Is + Offset )... >();
178}
180//*************************************************************************************************
181
182
183//*************************************************************************************************
191template< size_t... Is1 // The indices to be selected
192 , size_t... Is2 > // The sequence of indices
193constexpr decltype(auto) subsequence( std::index_sequence<Is2...> sequence )
194{
195 MAYBE_UNUSED( sequence );
196
197 constexpr size_t indices[] = { Is2... };
198 return std::index_sequence< indices[Is1]... >();
199}
201//*************************************************************************************************
202
203
204
205
206//=================================================================================================
207//
208// ALIAS DEFINITIONS
209//
210//=================================================================================================
211
212//*************************************************************************************************
225template< size_t Offset // The offset of the index sequence
226 , size_t N > // The total number of indices in the index sequence
227using make_shifted_index_sequence = decltype( shift<Offset>( make_index_sequence<N>() ) );
228//*************************************************************************************************
229
230
231//*************************************************************************************************
244template< size_t Offset // The offset of the index sequence
245 , size_t N // The total number of indices in the index sequence
246 , size_t ... Is > // The indices to be selected
248 decltype( subsequence<Is...>( shift<Offset>( make_index_sequence<N>() ) ) );
249//*************************************************************************************************
250
251} // namespace blaze
252
253#endif
Header file for the MAYBE_UNUSED function template.
Index sequence type of the Blaze library.
constexpr bool operator!=(index_sequence< I1s... > lhs, index_sequence< I2s... > rhs) noexcept
Inequality operator for the comparison of two index sequences.
Definition: IntegerSequence.h:146
constexpr bool operator==(index_sequence< I1s... > lhs, index_sequence< I2s... > rhs) noexcept
Equality operator for the comparison of two index sequences.
Definition: IntegerSequence.h:108
constexpr void MAYBE_UNUSED(const Args &...)
Suppression of unused parameter warnings.
Definition: MaybeUnused.h:81
decltype(subsequence< Is... >(shift< Offset >(make_index_sequence< N >()))) make_shifted_index_subsequence
Auxiliary alias declaration for the setup of shifted index subsequences.
Definition: IntegerSequence.h:248
decltype(shift< Offset >(make_index_sequence< N >())) make_shifted_index_sequence
Auxiliary alias declaration for the setup of shifted index sequences.
Definition: IntegerSequence.h:227