]>
Commit | Line | Data |
---|---|---|
4b2e63de | 1 | // { dg-do compile { target c++11 } } |
fa2200cb JM |
2 | |
3 | template<class T> | |
4 | struct IsNegative { | |
5 | int dummy; // Workaround for empty class problem | |
6 | constexpr IsNegative() : dummy(0) {} | |
7 | constexpr bool operator()(const T& x) { | |
8 | return x < T(0); | |
9 | } | |
10 | }; | |
11 | ||
12 | template<class T, int N, class Pred> | |
13 | constexpr bool has_neg(T (&x)[N], Pred p) { | |
14 | return p(x[0]) || p(x[1]); | |
15 | } | |
16 | ||
17 | constexpr int a[] = {1, -2}; | |
18 | ||
19 | constexpr auto answer = has_neg(a, IsNegative<int>{}); // #1 | |
20 | ||
21 | static_assert(answer, "Error"); |