Given this code fragment: -------------- struct Bag(S...) { alias S Types; } template Test(alias i, B) { void fn() { foreach(t; B.Types) { switch(i) { case IndexOf!(t, B.Types): { pragma(msg, __traits(allMembers, t)); pragma(msg, __traits(hasMember, t, "m")); break; } default: {} } } } } struct A { int m; } void main() { int i; alias Test!(i, Bag!(A)).fn func; } ---------------------- DMD will output: ---------------------- tuple("m") false --------------------- It seems that __traits(hasMember, ..) evaluates to false, despite the fact that the type does have a member "m". However if the template Test does not have an alias parameter, everything will work just fine.
I think this is an issue that both of D1 and D2 have. D2 patch: https://github.com/D-Programming-Language/dmd/pull/509
https://github.com/D-Programming-Language/dmd/commit/6fb5861528c7568d2546774a1c884f99594024c0 https://github.com/D-Programming-Language/dmd/commit/129c1ae7fe50cb3cb9a218e232f42f9a5a987e29
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル