On Thursday, 6 June 2013 at 17:50:08 UTC, Chris Williams wrote:
...
It will work if use "enum" instead of "auto" for storing
attribute tuple. If compile-time value is needed you almost
always want to store it in enum.
Here's how I do it:
enum Dump; // just a type, no value here
template Dumper(T) {
void dump() {
foreach (mem; __traits(allMembers, T)) {
// loop over the attrs instead of try to store them in a
var
foreach(attr; __traits(getAttributes, __traits(getMember,
T, mem)))
I decided to write up a little application to test using User
Defined Attributes and have one question. Here is a working
application that allows me to mark certain members of a function
to be dumped:
import std.stdio;
enum Dump = "Dump";
template Dumper(T) {
void dump() {