mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 21:51:40 +03:00
Merge pull request #8292 from andralex/iterative-largest
Iterative Largest
This commit is contained in:
commit
5ee65fc2e8
1 changed files with 3 additions and 19 deletions
22
std/traits.d
22
std/traits.d
|
@ -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);
|
||||
}
|
||||
|
||||
///
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue