fork download
  1. #include <boost/static_assert.hpp>
  2.  
  3. template<int N>
  4. struct is_power_of_two {
  5. enum {val = (N >= 1) & !(N & (N - 1))};
  6. BOOST_STATIC_ASSERT(val);
  7. };
  8.  
  9. int main() {
  10. is_power_of_two<5> p;
  11. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘is_power_of_two<5>’:
prog.cpp:10:   instantiated from here
prog.cpp:6: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’ 
prog.cpp: In function ‘int main()’:
prog.cpp:10: warning: unused variable ‘p’
stdout
Standard output is empty