1 // { dg-do compile { target c++11 } } 2 template<int I> 3 struct accept_evens { 4 static_assert( I % 2 == 0, "I must be an even number"); // { dg-error "even number" } 5 }; 6 7 template<int I> 8 struct accept_evens_ok { 9 static_assert( I % 2 == 0, "I must be an even number"); 10 }; 11 12 template<int I> accept_odds()13void accept_odds() { 14 static_assert( I % 2 == 1, "I must be an odd number"); // { dg-error "odd number" } 15 } 16 17 template<int I> accept_odds_ok()18void accept_odds_ok() { 19 static_assert( I % 2 == 1, "I must be an odd number"); 20 } 21 f()22void f() 23 { 24 accept_odds<1>(); 25 accept_odds<2>(); 26 accept_odds<3>(); 27 accept_odds_ok<5>(); 28 accept_odds_ok<7>(); 29 } 30 31 accept_evens<0> ok0; 32 accept_evens<1> error1; 33 accept_evens<2> ok2; 34 accept_evens_ok<4> ok4; 35 accept_evens_ok<6> ok6; 36