Bug 4292 – [PATCH] CommonType fails for singular alias value
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-06-07T16:35:00Z
Last change time
2015-06-09T01:31:21Z
Assigned to
nobody
Creator
simen.kjaras
Comments
Comment #0 by simen.kjaras — 2010-06-07T16:35:07Z
std.traits.CommonType does not correctly handle the situation of one single value (non-type) parameter, i.e. CommonType!3.
Solution here:
template CommonType(T...)
{
static if (!T.length)
alias void CommonType;
else static if (T.length == 1)
{
static if (is(typeof(T[0])))
alias typeof( T[0] ) commonOrSingleType;
else
alias T[0] commonOrSingleType;
}
else static if (is(typeof(true ? T[0].init : T[1].init) U))
alias CommonType!(U, T[2 .. $]) CommonType;
else
alias void CommonType;
}