static foreach / iterate over all consts in a module?

Nicholas Wilson iamthewilsonator at hotmail.com
Tue Mar 5 13:03:38 UTC 2019


On Sunday, 3 March 2019 at 19:20:00 UTC, Robert M. Münch wrote:
> If I want to iterate over all const WM_* windows message 
> definitions during compile time, can this be done with a static 
> foreach and the allMembers traits?
>
> Something like:
>
> static foreach(wm; __traits(allMembers, mymodule)) {
> 	static if(wm[1..3] == "WM_") {

> static foreach(wm; __traits(allMembers, mymodule)) {
> 	static if(wm.stringof[1..3] == "WM_") {



More information about the Digitalmars-d mailing list