Skip to content

Instantly share code, notes, and snippets.

@udaken
Last active January 27, 2018 14:41
Show Gist options
  • Save udaken/f7e662c1a61d663a5978d1f298f88cff to your computer and use it in GitHub Desktop.
Save udaken/f7e662c1a61d663a5978d1f298f88cff to your computer and use it in GitHub Desktop.
TMP(template meta programming) ビットカウント(C++)
template< unsigned long long N >
struct popcount
{
static const unsigned long long value = popcount< N / 2 >::value + (N % 2);
};
template<>
struct popcount< 0 >
{
static const unsigned long long value = 0;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment