summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/variadic-crash5.C
blob: 6866f39975ad2793fcceab8ffa63f99a2471c5fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// PR c++/81957
// { dg-do compile { target c++11 } }

template <class T, T v>
struct integral_constant { };

struct f {
  template<bool b, typename Int>
  void operator()(integral_constant<bool,b>, Int i) {
  }
};

template<bool...Bs, typename F, typename ...T>
auto dispatch(F f, T...t) -> decltype(f(integral_constant<bool,Bs>()..., t...)) {
  return f(integral_constant<bool,Bs>()..., t...);
}

template<bool...Bs, typename F, typename ...T>
auto dispatch(F f, bool b, T...t) -> decltype(dispatch<Bs..., true>(f, t...)) {
  if (b)
    return dispatch<Bs..., true>(f, t...);
  else
    return dispatch<Bs..., false>(f, t...);
}

int main() {
  dispatch(f(), true, 5);
}