fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <int N>
  5. struct clog2
  6. {
  7. enum { value = clog2<(N >> 1)>::value + 1 };
  8. };
  9.  
  10. template <>
  11. struct clog2<1>
  12. {
  13. enum { value = 0 };
  14. };
  15.  
  16.  
  17. int main() {
  18. printf("%d\n", clog2<500>::value);
  19. printf("%d\n", clog2<600>::value);
  20. return 0;
  21. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
8
9