[Issue 23272] [REG2.099] CTFE error of typeid comparison ==
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue Dec 20 19:35:54 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=23272
--- Comment #3 from Iain Buclaw <ibuclaw at gdcproject.org> ---
Possible reduction of the original.
---
alias AliasSeq(TList...) = TList;
template EnumMembers(E)
{
alias EnumMembers = AliasSeq;
static foreach (M; __traits(allMembers, E))
EnumMembers = AliasSeq!(__traits(getMember, E, M));
}
struct SumType(Ts)
{
mixin(() {
auto s = "enum Cases : ubyte {";
return s ~= "unset}\n";
}());
Cases which;
union {
Ts cases;
}
}
auto caseOfTemplated(alias func, T)(T s) {
final switch (s.which) foreach(CASE; EnumMembers!(T.Cases)) {
case CASE:
return func(s.cases);
}
}
void foo() {
bool validate() {
SumType!(int) s;
caseOfTemplated!(a => typeid(a))(s) == typeid(string);
return true;
}
static assert(validate);
}
--
More information about the Digitalmars-d-bugs
mailing list