Skip to content

Instantly share code, notes, and snippets.

@magurosan
Last active August 15, 2017 20:47
Show Gist options
  • Save magurosan/c27cd2ce337eed9e26a838c32ef4cd5f to your computer and use it in GitHub Desktop.
Save magurosan/c27cd2ce337eed9e26a838c32ef4cd5f to your computer and use it in GitHub Desktop.
static tzcnt
struct static_tzcnt {
constexpr size_t operator ()(size_t x) const {
return (x == 0) ? (sizeof(size_t) * 8)
: ((x & 1)? 0 : (1 + operator()(x >> 1)));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment