Created
March 30, 2017 16:39
-
-
Save merryhime/6a8b2f411add8fa750f9ff00d6ab88ac to your computer and use it in GitHub Desktop.
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
template <typename T> | |
constexpr T pext(T x, T mask) { | |
T ret = 0; | |
for (T bb = 1; mask != 0; bb += bb) { | |
if (x & mask & -mask) { | |
ret |= bb; | |
} | |
mask &= (mask - 1); | |
} | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment