6#ifndef DUNE_COMMON_INDICES_HH
7#define DUNE_COMMON_INDICES_HH
28 template<std::
size_t i>
123 template<
class F,
class I, I... i>
126 return f(std::integral_constant<I, i>()...);
130 namespace Indices {
inline namespace Literals
135 constexpr unsigned char2digit (
const char c)
137 if (c >=
'0' && c <=
'9')
138 return unsigned(c) - unsigned(
'0');
140 throw std::invalid_argument(
"Character is not a digit.");
146 template <
class T,
char... digits>
147 constexpr T chars2number ()
149 const char arr[] = {digits...};
154 const int N =
sizeof...(digits);
155 for (
int i = 0; i < N; ++i) {
156 char c = arr[N - 1 - i];
157 result+= char2digit(c) *
power;
172 template <
char... digits>
173 constexpr auto operator"" _ic()
175 return std::integral_constant<std::size_t, Impl::chars2number<std::size_t,digits...>()>{};
184 template <
char... digits>
185 constexpr auto operator"" _uc()
187 return std::integral_constant<unsigned, Impl::chars2number<unsigned,digits...>()>{};
196 template <
char... digits>
197 constexpr auto operator"" _sc()
199 return std::integral_constant<int, Impl::chars2number<int,digits...>()>{};
208 template <
class T, T value>
209 constexpr auto operator- (std::integral_constant<T,value>)
211 return std::integral_constant<std::make_signed_t<T>, -value>{};
constexpr index_constant< 16 > _16
Compile time index with value 16.
Definition indices.hh:100
constexpr index_constant< 15 > _15
Compile time index with value 15.
Definition indices.hh:97
constexpr index_constant< 8 > _8
Compile time index with value 8.
Definition indices.hh:76
constexpr index_constant< 7 > _7
Compile time index with value 7.
Definition indices.hh:73
constexpr index_constant< 0 > _0
Compile time index with value 0.
Definition indices.hh:52
constexpr index_constant< 9 > _9
Compile time index with value 9.
Definition indices.hh:79
constexpr index_constant< 14 > _14
Compile time index with value 14.
Definition indices.hh:94
constexpr index_constant< 1 > _1
Compile time index with value 1.
Definition indices.hh:55
constexpr index_constant< 3 > _3
Compile time index with value 3.
Definition indices.hh:61
constexpr index_constant< 12 > _12
Compile time index with value 12.
Definition indices.hh:88
decltype(auto) constexpr unpackIntegerSequence(F &&f, std::integer_sequence< I, i... > sequence)
Unpack an std::integer_sequence<I,i...> to std::integral_constant<I,i>...
Definition indices.hh:124
constexpr auto operator-(std::integral_constant< T, value >)
Negation operator for integral constants.
Definition indices.hh:209
constexpr index_constant< 11 > _11
Compile time index with value 11.
Definition indices.hh:85
constexpr index_constant< 18 > _18
Compile time index with value 18.
Definition indices.hh:106
constexpr index_constant< 13 > _13
Compile time index with value 13.
Definition indices.hh:91
constexpr index_constant< 5 > _5
Compile time index with value 5.
Definition indices.hh:67
constexpr index_constant< 17 > _17
Compile time index with value 17.
Definition indices.hh:103
constexpr index_constant< 10 > _10
Compile time index with value 10.
Definition indices.hh:82
constexpr index_constant< 2 > _2
Compile time index with value 2.
Definition indices.hh:58
std::integral_constant< std::size_t, i > index_constant
An index constant with value i.
Definition indices.hh:29
constexpr index_constant< 19 > _19
Compile time index with value 19.
Definition indices.hh:109
constexpr index_constant< 6 > _6
Compile time index with value 6.
Definition indices.hh:70
constexpr index_constant< 4 > _4
Compile time index with value 4.
Definition indices.hh:64
Dune namespace.
Definition alignedallocator.hh:13
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition math.hh:75