fork(6) download
  1. #include<iostream>
  2.  
  3. template<int N>
  4. struct is_power_of_two {
  5. enum {val = (N > 1) & !(N & (N - 1))};
  6. static_assert(val, "should use a power of 2 as template parameter");
  7. };
  8.  
  9. int main()
  10. {
  11. std::cout << is_power_of_two<2>::val << "\n";
  12. std::cout << is_power_of_two<3>::val << "\n";
  13. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of 'is_power_of_two<3>':
prog.cpp:12:33:   instantiated from here
prog.cpp:6:5: error: static assertion failed: "should use a power of 2 as template parameter"
stdout
Standard output is empty