D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 4292 - [PATCH] CommonType fails for singular alias value
Summary: [PATCH] CommonType fails for singular alias value
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-06-07 16:35 UTC by Simen Kjaeraas
Modified: 2015-06-09 01:31 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Simen Kjaeraas 2010-06-07 16:35:07 UTC
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;
}
Comment 1 David Simcha 2010-08-15 08:05:10 UTC
Fixed SVN.