#include<iostream> template<int N>struct is_power_of_two { enum {val = (N > 1) & !(N & (N - 1))}; static_assert(val, "should use a power of 2 as template parameter");}; int main(){ std::cout << is_power_of_two<2>::val << "\n"; std::cout << is_power_of_two<3>::val << "\n";}
Standard input is empty
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"
Standard output is empty
The brand new service which powers Ideone!
Widget for compiling and running the source code in a web browser!