On Wednesday, 16 October 2013 at 12:26:34 UTC, John Colvin wrote:
It seems that __traits(getAttributes, T) returns an empty tuple
for any template (or template function) T, no matter what UDAs
T has been given.
Am I doing something wrong?
@(1) void foo(T)(){}
pragma(msg, __traits(getAttributes, foo)); // tuple()
pragma(msg, __traits(getAttributes, foo!int)); // tuple(1)
I think this gets re-written like this:
template foo(T)
{
@(1) void foo() {}
}
..which does explain the observed behavior. As a workaround you
can define some default guard value of T and assert inside foo()
call if it is actually ever used.