fork(1) download
  1. #include <bitset>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. //template <unsigned int x>
  7. //constexpr int log2() {
  8. // return x < 4 ? 1 : 1 + log2<x / 2>();
  9. //}
  10.  
  11. constexpr int log2(const unsigned int x) {
  12. return x < 4 ? 1 : 1 + log2(x / 2);
  13. }
  14.  
  15. int main() {
  16. bitset<log2(2)> foo;
  17. int bar[log2(8)];
  18.  
  19. cout << log2(8) << endl;
  20. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
3