1 /**
2     TODO
3 
4     License:   $(HTTP www.boost.org/LICENSE_1_0.txt, Boost License 1.0).
5     Authors:   Adam Búš
6 */
7 module btl.traits.assume;
8 
9 import std.traits : isFunctionPointer, isDelegate;
10 
11 
12 
13 /**
14     TODO
15 */
16 public auto assumeNoGC(T)(T fn)@trusted
17 in(isFunctionPointer!T || isDelegate!T){
18     import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage;
19 
20     enum attrs = functionAttributes!T | FunctionAttribute.nogc;
21     return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn;
22 }
23 
24 
25 
26 /**
27     TODO
28 */
29 public auto assumePure(T)(T fn)@trusted
30 in(isFunctionPointer!T || isDelegate!T){
31     import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage;
32 
33     enum attrs = functionAttributes!T | FunctionAttribute.pure_;
34     return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn;
35 }
36 
37 
38 
39 /**
40     TODO
41 */
42 public auto assumePureNoGc(T)(T fn)@trusted
43 in(isFunctionPointer!T || isDelegate!T){
44     import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage;
45 
46     enum attrs = functionAttributes!T | FunctionAttribute.pure_ | FunctionAttribute.nogc;
47     return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn;
48 }
49 
50 
51 
52 /**
53     TODO
54 */
55 public auto assumePureNoGcNothrow(T)(T fn)@trusted
56 in(isFunctionPointer!T || isDelegate!T){
57     import std.traits : functionAttributes, FunctionAttribute, SetFunctionAttributes, functionLinkage;
58 
59     enum attrs = functionAttributes!T | FunctionAttribute.pure_ | FunctionAttribute.nogc | FunctionAttribute.nothrow_;
60     return cast(SetFunctionAttributes!(T, functionLinkage!T, attrs)) fn;
61 }
62