5#include <dune/common/hybridutilities.hh>
6#include <dune/common/rangeutilities.hh>
11 template <
class T, T to, T from,
class Value,
class Then,
class Else>
12 constexpr decltype(
auto) switchCases(
const Dune::StaticIntegralRange<T,to,from>& cases,
const Value& value,
13 Then&& thenBranch, Else&& elseBranch)
15 using integer_sequence =
typename Dune::StaticIntegralRange<T,to,from>::integer_sequence;
16 return Dune::Hybrid::switchCases(integer_sequence{}, value, FWD(thenBranch), FWD(elseBranch));
20 template <
class T,
class Value,
class Then,
class Else>
21 constexpr decltype(
auto) switchCases(
const Dune::IntegralRange<T>& cases,
const Value& value,
22 Then&& thenBranch, Else&& elseBranch)
24 if (value >= cases[0] && value <= cases[cases.size()-1])
25 return thenBranch(value);
27 return elseBranch(value);
31 template<
class T, T to, T from,
class Value,
class Then>
32 constexpr void switchCases(
const Dune::StaticIntegralRange<T,to,from>& cases,
const Value& value, Then&& thenBranch)
34 using integer_sequence =
typename Dune::StaticIntegralRange<T,to,from>::integer_sequence;
35 Dune::Hybrid::switchCases(integer_sequence{}, value, FWD(thenBranch));
39 template<
class T,
class Value,
class Then>
40 constexpr void switchCases(
const Dune::IntegralRange<T>& cases,
const Value& value, Then&& thenBranch)
42 assert(value >= cases[0] && value <= cases[cases.size()-1]);