1 // { dg-do compile { target c++11 } } 2 3 template<class T> 4 struct IsNegative { 5 int dummy; // Workaround for empty class problem IsNegativeIsNegative6 constexpr IsNegative() : dummy(0) {} operatorIsNegative7 constexpr bool operator()(const T& x) { 8 return x < T(0); 9 } 10 }; 11 12 template<class T, int N, class Pred> has_neg(T (& x)[N],Pred p)13constexpr 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"); 22