Last active
February 9, 2023 23:34
-
-
Save kubo39/ad356d60f2ca8c51267a7ea1787f4bfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import std; | |
static assert(isInstanceOf!(Array, Array!char)); | |
static assert(!isInstanceOf!(Regex, Regex!char)); | |
static assert(isInstanceOf!(TemplateOf!(Regex!char), Regex!char)); | |
static assert(__traits(isSame, TemplateOf!(Array!char), Array)); | |
static assert(!__traits(isSame, TemplateOf!(Regex!char), Regex)); | |
static if (is(Array!char == T1!Args1, alias T1, Args1...)) | |
{ | |
static assert(__traits(isSame, T1, Array)); | |
pragma(msg, T1); // Array(T) if (!is(immutable(T) == immutable(bool))) | |
static assert(__traits(isTemplate, T1)); | |
pragma(msg, __traits(identifier, T1)); // Array | |
pragma(msg, T1!char); // Array!char | |
static assert(is(T1!char == Array!char)); | |
static assert(is(Args1[0] == char)); | |
} | |
static if (is(Regex!char == T2!Args2, alias T2, Args2...)) | |
{ | |
static assert(!__traits(isSame, T2, Regex)); | |
pragma(msg, T2); // Regex(Char) | |
static assert(__traits(isTemplate, Regex)); | |
static assert(__traits(isTemplate, T2)); | |
pragma(msg, __traits(identifier, T2)); // Regex | |
pragma(msg, T2!char); // Regex!char | |
static assert(is(T2!char == Regex!char)); | |
static assert(is(Args2[0] == char)); | |
} | |
struct S1(Char) {} | |
public alias S2(Char) = S1!Char; | |
static if (is(S1!char == T3!Args3, alias T3, Args3...)) | |
{ | |
static assert(__traits(isSame, T3, S1)); | |
pragma(msg, T3); // S1(Char) | |
static assert(__traits(isTemplate, S1)); | |
static assert(__traits(isTemplate, T3)); | |
pragma(msg, __traits(identifier, T3)); // S1 | |
pragma(msg, T3!char); // S1!char | |
static assert(is(T3!char == S1!char)); | |
static assert(is(Args3[0] == char)); | |
} | |
static if (is(S2!char == T4!Args4, alias T4, Args4...)) | |
{ | |
static assert(!__traits(isSame, T4, S2)); | |
pragma(msg, T4); // S1(Char) | |
static assert(__traits(isTemplate, S2)); | |
static assert(__traits(isTemplate, T4)); | |
pragma(msg, __traits(identifier, T4)); // S1 | |
pragma(msg, T4!char); // S1!char | |
static assert(is(T4!char == S2!char)); | |
static assert(is(Args4[0] == char)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment