auto function attributes based on type

amber via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 11 22:01:49 PDT 2015


On Thursday, 12 March 2015 at 04:51:42 UTC, amber wrote:
> On Thursday, 12 March 2015 at 04:04:28 UTC, weaselcat wrote:
>> On Thursday, 12 March 2015 at 03:12:15 UTC, amber wrote:
>>> ...
>> http://dlang.org/function.html#function-attribute-inference 
>> might be a good read if you haven't read it already.
>
> I did read it but didn't really understand it, so I've come to 
> D.learn for more help.
>
> I think it means I can just write the function like so:
>
> struct S(T) {
>     someFunc(int i) {// impl}
> }
>
> and if possible it will be pure, nothrow, @safe and @nogc.
>
>
>
> thanks,
> amber

This works nicely after checking with 
__traits(getFunctionAttributes, S!T.someFunc)

Very cool :)

bye,
amber





More information about the Digitalmars-d-learn mailing list