summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/cpp0x/static_assert2.C
blob: 3e74bb1b480c58020ca29f95bea3011bab7eaaff (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
29
30
31
32
33
34
35
// { dg-options "-std=c++0x" }
template<int I>
struct accept_evens {
  static_assert( I % 2 == 0, "I must be an even number"); // { dg-error "even number" }
};

template<int I>
struct accept_evens_ok {
  static_assert( I % 2 == 0, "I must be an even number");
};

template<int I>
void accept_odds() {
  static_assert( I % 2 == 1, "I must be an odd number"); // { dg-error "odd number" }
}

template<int I>
void accept_odds_ok() {
  static_assert( I % 2 == 1, "I must be an odd number");
}

void f()
{
  accept_odds<1>();
  accept_odds<2>(); 
  accept_odds<3>();
  accept_odds_ok<5>();
  accept_odds_ok<7>();
}

accept_evens<0> ok0;
accept_evens<1> error1; 
accept_evens<2> ok2;
accept_evens_ok<4> ok4;
accept_evens_ok<6> ok6;