-
-
Notifications
You must be signed in to change notification settings - Fork 696
Closed
Labels
Description
Andrei Alexandrescu (@andralex) reported this on 2020-05-25T18:30:05Z
Transferred from https://issues.dlang.org/show_bug.cgi?id=20863
CC List
- Boris Carvajal
- Adam D. Ruppe
- John Colvin
- Max Samukha
- Nick Treleaven (@ntrel)
- Steven Schveighoffer (@schveiguy)
Description
Took me a while to make this 100% self-contained. Both asserts should pass. The second fails.
alias AliasSeq(Seq...) = Seq;
template staticIndexOf(alias T, TList...)
{
static if (TList.length == 0)
{
enum int staticIndexOf = -1;
}
else static if (is(T == TList[0]))
{
enum int staticIndexOf = 0;
}
else
{
private enum int t = staticIndexOf!(T, TList[1 .. $]);
enum int staticIndexOf = t < 0 ? t : t + 1;
}
}
struct Foo {}
static assert(staticIndexOf!(Foo, AliasSeq!(Foo)) == 0); // pass
static assert(staticIndexOf!(immutable(Foo), AliasSeq!(immutable(Foo))) == 0); // failReactions are currently unavailable