On Monday, 29 December 2014 at 16:03:41 UTC, Julian Kranz wrote:
On Monday, 29 December 2014 at 15:53:25 UTC, Steven Schveighoffer wrote:
The compiler can infer attributes if a function is a template. Not all attributes, but some of them.

-Steve

Ah, thanks, this explains it ;-). However, it's kind of uncool that this only works for templates...

I've gotten into the habit of templating every function, even if its a zero-parameter template, because trying to manage all the pure/safe/const/nothrow annotations myself always winds up putting me in a corner once the code starts to grow. It's not so bad, really, one advantage is that you can define functions that may or may not compile, but will only trigger an error if they are called on a type that doesn't support it. You can issue compile time branches using "static if (is (typeof(function_name)))" to gain an extra degree of control over this process.

Reply via email to