Mercurial > hg > CbC > CbC_gcc
comparison gcc/testsuite/g++.dg/cpp0x/variadic-crash5.C @ 131:84e7813d76e9
gcc-8.2
author | mir3636 |
---|---|
date | Thu, 25 Oct 2018 07:37:49 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
111:04ced10e8804 | 131:84e7813d76e9 |
---|---|
1 // PR c++/81957 | |
2 // { dg-do compile { target c++11 } } | |
3 | |
4 template <class T, T v> | |
5 struct integral_constant { }; | |
6 | |
7 struct f { | |
8 template<bool b, typename Int> | |
9 void operator()(integral_constant<bool,b>, Int i) { | |
10 } | |
11 }; | |
12 | |
13 template<bool...Bs, typename F, typename ...T> | |
14 auto dispatch(F f, T...t) -> decltype(f(integral_constant<bool,Bs>()..., t...)) { | |
15 return f(integral_constant<bool,Bs>()..., t...); | |
16 } | |
17 | |
18 template<bool...Bs, typename F, typename ...T> | |
19 auto dispatch(F f, bool b, T...t) -> decltype(dispatch<Bs..., true>(f, t...)) { | |
20 if (b) | |
21 return dispatch<Bs..., true>(f, t...); | |
22 else | |
23 return dispatch<Bs..., false>(f, t...); | |
24 } | |
25 | |
26 int main() { | |
27 dispatch(f(), true, 5); | |
28 } |