Iterating over functions in module in order?
Alex
sascha.orlov at gmail.com
Fri Oct 6 21:44:37 UTC 2017
On Thursday, 5 October 2017 at 00:24:12 UTC, Jerry wrote:
> Any ideas on how someone could iterate over functions in a
> module as they appear, rather than any random order, without
> having to manually label them?
Do you mean something like this?
/// --- code ---
module test165;
import std.stdio;
import std.traits : isFunction;
void main()
{
immutable b = [ __traits(allMembers, mixin(__MODULE__)) ];
static foreach(i, _; b)
static if(isFunction!(__traits(getMember, mixin(__MODULE__),
b[i])))
writeln(b[i]);
}
auto fun1(){}
struct S;
int i;
double[] arr;
auto fun3(int val){}
auto fun2(T)(T notAfun) {}
/// --- code ---
I saw a similar problem here:
http://forum.dlang.org/post/xratcdpxfepxowghjyxd@forum.dlang.org
More information about the Digitalmars-d-learn
mailing list