mirror of
https://github.com/dlang/phobos.git
synced 2025-05-09 04:27:23 +03:00
Merge pull request #4327 from tsbockman/isPowerOf2
Add `std.math.isPowerOf2()`. Supports floating-point and integers.
This commit is contained in:
commit
7172eda466
8 changed files with 131 additions and 46 deletions
|
@ -4632,7 +4632,8 @@ if (isForwardRange!R && !isRandomAccessRange!R)
|
|||
private auto sumPairwiseN(size_t N, bool needEmptyChecks, F, R)(ref R r)
|
||||
if (isForwardRange!R && !isRandomAccessRange!R)
|
||||
{
|
||||
static assert(!(N & (N-1))); //isPow2
|
||||
import std.math : isPowerOf2;
|
||||
static assert(isPowerOf2(N));
|
||||
static if (N == 2) return sumPair!(needEmptyChecks, F)(r);
|
||||
else return sumPairwiseN!(N/2, needEmptyChecks, F)(r)
|
||||
+ sumPairwiseN!(N/2, needEmptyChecks, F)(r);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue