This works: template classMixin() { static this() { const string[] members = __traits(allMembers, typeof(this)); pragma(msg, foo(members)); } } string foo(const string[] members) { string result; foreach(m; members) result ~= m ~ " "; return result; } But there must exist a better solution to this.