| 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 |
} |