On 07/19/2016 08:55 AM, Rufus Smith wrote:
I have some functions that take other functions. I would like the
attributes to be able to "fall" through so I get overload like behavior.
I only care that I am passing a function, not if it is shared,
extern(C), pure, @nogc, etc.
void foo(R, A...)(R function(A) bar)
{
alias type = typeof(bar);
pragma(msg, type);
// does magic with bar
}
foo never uses the attributes of bar explicitly. It uses type to
instantiate other functions like bar. I have to create a foo for each
attribute combination, which is not worth while. The code seems to break
only for extern, the best I can tell, most attributes do pass through.
But type does not contain these attributes.
functionAttributes may be useful. SetFunctionAttributes has an example:
https://dlang.org/phobos/std_traits.html#SetFunctionAttributes
Ali