Comparing two AliasSeq
H. S. Teoh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Mar 24 21:15:13 PDT 2017
On Sat, Mar 25, 2017 at 03:25:27AM +0000, Yuxuan Shui via Digitalmars-d-learn wrote:
> In this example:
>
> import std.range;
> template expandRange(alias R) if (isInputRange!(typeof(R))) {
> static if (R.empty)
> alias expandRange = AliasSeq!();
> else
> alias expandRange = AliasSeq!(R.front(), expandRange!(R.drop(1)));
> }
>
> ///
> unittest {
> import std.range;
> static assert (is(expandRange!(iota(0,5)): AliasSeq!(0,1,2,3,4)));
> }
>
> The static assert fails, why?
Firstly, is(T : U) expects T and U to be types, and expandRange!(...) is
not a type (or a list of types), it is a list of values.
Second, is(T : U) means "does the type T implicitly convert to the type
U?". It checks for implicit convertibility between types, it does not
compare values.
T
--
The right half of the brain controls the left half of the body. This means that only left-handed people are in their right mind. -- Manoj Srivastava
More information about the Digitalmars-d-learn
mailing list