Created
May 11, 2021 03:34
-
-
Save opensvn/207e1bf3528fdb8ca56163b2ace7138e to your computer and use it in GitHub Desktop.
OnesCount
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
template <size_t Input> | |
constexpr size_t OnesCount = (Input % 2) + OnesCount<(Input / 2)>; | |
template <> constexpr size_t OnesCount<0> = 0; | |
int main() { | |
std::cout << OnesCount<45> << std::endl; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment