rocPRIM
integer_sequence.hpp
1 // Copyright (c) 2018-2020 Advanced Micro Devices, Inc. All rights reserved.
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 // THE SOFTWARE.
20 
21 #ifndef ROCPRIM_TYPES_INTEGER_SEQUENCE_HPP_
22 #define ROCPRIM_TYPES_INTEGER_SEQUENCE_HPP_
23 
24 #include <type_traits>
25 
26 #include "../config.hpp"
27 
28 BEGIN_ROCPRIM_NAMESPACE
29 #if defined(__cpp_lib_integer_sequence) && !defined(DOXYGEN_SHOULD_SKIP_THIS)
30 // For C++14 or newer we just use standard implementation
31 using std::integer_sequence;
32 using std::index_sequence;
33 using std::make_integer_sequence;
34 using std::make_index_sequence;
35 using std::index_sequence_for;
36 #else
37 template<class T, T... Ints>
43 {
44  using value_type = T;
45 
46  static inline constexpr size_t size() noexcept
47  {
48  return sizeof...(Ints);
49  }
50 };
51 
55 template<size_t... Ints>
56 using index_sequence = integer_sequence<size_t, Ints...>;
57 
58 // DETAILS
59 namespace detail
60 {
61 
62 template<class T, class IntegerSequence>
64 
65 template<class T, T... Indices>
66 struct integer_sequence_cat<T, ::rocprim::integer_sequence<T, Indices...>>
67 {
68  using type = typename ::rocprim::integer_sequence<T, Indices..., sizeof...(Indices)>;
69 };
70 
71 template<class T, size_t Count>
73  integer_sequence_cat<T, typename make_integer_sequence_impl<T, Count - 1>::type>
74 {
75 };
76 
77 template<class T>
79 {
80  using type = ::rocprim::integer_sequence<T>;
81 };
82 
83 } // end detail namespace
84 
88 template<class T, T N>
89 using make_integer_sequence = typename detail::make_integer_sequence_impl<T, N>::type;
90 
93 template<size_t N>
94 using make_index_sequence = make_integer_sequence<size_t, N>;
95 
99 template<class... T>
100 using index_sequence_for = make_index_sequence<sizeof...(T)>;
101 #endif
102 
103 END_ROCPRIM_NAMESPACE
104 
105 #endif // ROCPRIM_TYPES_INTEGER_SEQUENCE_HPP_
Definition: integer_sequence.hpp:63
Deprecated: Configuration of device-level scan primitives.
Definition: block_histogram.hpp:62
Definition: integer_sequence.hpp:72
Compile-time sequence of integers.
Definition: integer_sequence.hpp:42