Merge pull request #8292 from andralex/iterative-largest

Iterative Largest
This commit is contained in:
Razvan Nitu 2021-10-19 10:40:24 +03:00 committed by GitHub
commit 5ee65fc2e8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -8046,25 +8046,9 @@ returned.
template Largest(T...)
if (T.length >= 1)
{
static if (T.length == 1)
{
alias Largest = T[0];
}
else static if (T.length == 2)
{
static if (T[0].sizeof >= T[1].sizeof)
{
alias Largest = T[0];
}
else
{
alias Largest = T[1];
}
}
else
{
alias Largest = Largest!(Largest!(T[0 .. $/2]), Largest!(T[$/2 .. $]));
}
alias Largest = T[0];
static foreach (U; T[1 .. $])
Largest = Select!(U.sizeof > Largest.sizeof, U, Largest);
}
///