Skip to content

Commit

Permalink
Merge pull request #8288 from andralex/simplerCommonType
Browse files Browse the repository at this point in the history
[TRIVIAL] Simpler CommonType
  • Loading branch information
RazvanN7 authored Oct 18, 2021
2 parents b5ea06d + f5c15d8 commit 9252a88
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions std/traits.d
Original file line number Diff line number Diff line change
Expand Up @@ -4859,25 +4859,10 @@ types have no common type.
*/
template CommonType(T...)
{
static if (!T.length)
{
alias CommonType = void;
}
else static if (T.length == 1)
{
static if (is(typeof(T[0])))
{
alias CommonType = typeof(T[0]);
}
else
{
alias CommonType = T[0];
}
}
static if (T.length == 1)
alias CommonType = typeof(T[0].init);
else static if (is(typeof(true ? T[0].init : T[1].init) U))
{
alias CommonType = CommonType!(U, T[2 .. $]);
}
else
alias CommonType = void;
}
Expand Down

0 comments on commit 9252a88

Please sign in to comment.