dune-common  2.5.0
utility.hh
Go to the documentation of this file.
1 #ifndef DUNE_COMMON_STD_UTILITY_HH
2 #define DUNE_COMMON_STD_UTILITY_HH
3 
4 #include <cstddef>
5 
6 #include <type_traits>
7 #include <utility>
8 
10 
11 namespace Dune
12 {
13 
14  namespace Std
15  {
16 
17 
18 #if __cpp_lib_integer_sequence >= 201304
19 
20  using std::integer_sequence;
21  using std::index_sequence;
24 
25 #else // __cpp_lib_integer_sequence >= 201304
26 
27  // integer_sequence
28  // ----------------
29 
35  template< class T, T... Ints >
37  {
38  static_assert( std::is_integral< T >::value, "Template parameter T is required to be an integral type" );
39 
40  public:
41 
43  typedef T value_type;
44 
46  static constexpr std::size_t size () { return sizeof...( Ints ); }
47  };
48 
49 
54  template< std::size_t... Ints >
55  using index_sequence = integer_sequence< std::size_t, Ints... >;
56 
57 #ifndef DOXYGEN
58 
59  namespace impl {
60 
61  template<typename T, T i, T n, T... indices>
62  struct _make_integer_sequence
63  : public _make_integer_sequence<T,i+1,n,indices...,i>
64  {};
65 
66  template<typename T, T n, T... indices>
67  struct _make_integer_sequence<T,n,n,indices...>
68  {
69  using type = integer_sequence<T,indices...>;
70  };
71 
72  }
73 
74 #endif // DOXYGEN
75 
76  template<typename T, T n>
77  using make_integer_sequence = typename impl::_make_integer_sequence<T,0,n>::type;
78 
79  template<std::size_t n>
81 
82 #endif // __cpp_lib_integer_sequence >= 201304
83 
98  template<typename... T>
100 
101 
102 
103  } // namespace Std
104 
105 } // namespace Dune
106 
107 #endif // #ifndef DUNE_COMMON_STD_UTILITY_HH
make_index_sequence< typename Dune::SizeOf< T... >{}> index_sequence_for
Create index_sequence from 0 to sizeof...(T)-1.
Definition: utility.hh:99
T value_type
value type
Definition: utility.hh:38
Dune namespace.
Definition: alignment.hh:10
Traits for type conversions and type information.
static constexpr std::size_t size()
return number of elements in sequence
Definition: utility.hh:46
typename impl::_make_integer_sequence< T, 0, n >::type make_integer_sequence
Definition: utility.hh:77
an implementation of std::integer_sequence as introduced in C++14
Definition: utility.hh:36
Compute size of variadic type list.
Definition: typetraits.hh:564
integer_sequence< std::size_t, Ints... > index_sequence
std::index_sequence as introduced in C++14
Definition: utility.hh:55
make_integer_sequence< std::size_t, n > make_index_sequence
Definition: utility.hh:80