fork(2) download
  1. #include<iostream>
  2. #include <boost/static_assert.hpp>
  3.  
  4. template<int N>
  5. struct is_power_of_two
  6. {
  7. enum { val = (N > 1) & !(N & (N - 1)) };
  8. //static_assert(val, "should use a power of 2 as template parameter");
  9. BOOST_STATIC_ASSERT(val);
  10. };
  11.  
  12. int main()
  13. {
  14. std::cout << is_power_of_two<2>::val << "\n";
  15. std::cout << is_power_of_two<3>::val << "\n";
  16. }
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:15:   instantiated from here
prog.cpp:9: error: invalid application of ‘sizeof’ to incomplete type ‘boost::STATIC_ASSERTION_FAILURE<false>’ 
stdout
Standard output is empty