On Sunday, 8 September 2013 at 13:46:26 UTC, Dicebot wrote:
http://dpaste.dzfl.pl/c250e798import std.traits, std.range; private template Methods(T) if (is(T == class)) { private string[] getMethods() { string result[]; foreach (member_string; __traits(allMembers, T)) {mixin("alias member = " ~ T.stringof ~ "." ~ member_string ~ ";");static if (is(typeof(member) == function)) { result ~= __traits(identifier, member); } } return result; } enum Methods = getMethods().join("\n"); } class A { int a; void delegate() dg; void foo() { } } void main() { pragma(msg, Methods!A); }
This looks like a nice solution but i get errors when used across modules. The problem is that allmembers emits private members so across modules they are not available.
