mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 22:21:09 +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
20
std/traits.d
20
std/traits.d
|
@ -8045,26 +8045,10 @@ returned.
|
||||||
*/
|
*/
|
||||||
template Largest(T...)
|
template Largest(T...)
|
||||||
if (T.length >= 1)
|
if (T.length >= 1)
|
||||||
{
|
|
||||||
static if (T.length == 1)
|
|
||||||
{
|
{
|
||||||
alias Largest = T[0];
|
alias Largest = T[0];
|
||||||
}
|
static foreach (U; T[1 .. $])
|
||||||
else static if (T.length == 2)
|
Largest = Select!(U.sizeof > Largest.sizeof, U, Largest);
|
||||||
{
|
|
||||||
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 .. $]));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue