1 #include <cstdlib> 2 #include <iostream> 3 4 enum { SIZE_PER_CHUNK = ((1<<16) / sizeof(unsigned)) }; 5 6 class TrueType {} ; 7 class FalseType {} ; 8 9 template< std::size_t V, bool B = (((V) & ((V) - 1)) == 0) > class IsPowerOfTwo_; 10 template< std::size_t V > class IsPowerOfTwo_< V, true > : public TrueType {}; 11 template< std::size_t V > class IsPowerOfTwo_< V, false > : public FalseType {}; 12 13 typedef IsPowerOfTwo_< SIZE_PER_CHUNK > IsPowerOfTwo; 14 15 16 int main() { 17 IsPowerOfTwo p2; 18 19 std::cout << "Hello World!" << std::endl; 20 return 0; 21 }
The following code gives a warning about the compiler (gcc 4.6.2, / project / dfttools / compile / lnx-x86 / gcc-4.6.2):
warning: suggest parentheses around '-' in operand '&' [-Wparentheses]
The warning points to line 13, but this is probably due to the expression on line 9.
Any solution?
source share