| 1 |
auto inferNothrow() |
| 2 |
in |
| 3 |
{ |
| 4 |
} |
| 5 |
out |
| 6 |
{ |
| 7 |
} |
| 8 |
do |
| 9 |
{ |
| 10 |
return 1; |
| 11 |
} |
| 12 |
|
| 13 |
auto dontInferNothrowIn() |
| 14 |
in |
| 15 |
{ |
| 16 |
throw new Exception(null); |
| 17 |
} |
| 18 |
do |
| 19 |
{ |
| 20 |
return 1; |
| 21 |
} |
| 22 |
|
| 23 |
auto dontInferNothrowOut() |
| 24 |
out |
| 25 |
{ |
| 26 |
throw new Exception(null); |
| 27 |
} |
| 28 |
do |
| 29 |
{ |
| 30 |
return 1; |
| 31 |
} |
| 32 |
|
| 33 |
enum isNothrow(Attr...) = (Attr.length >= 1) |
| 34 |
&& (Attr[0] == "nothrow" || isNothrow!(Attr[1 .. $])); |
| 35 |
|
| 36 |
static assert(isNothrow!(__traits(getFunctionAttributes, inferNothrow))); |
| 37 |
static assert(!isNothrow!(__traits(getFunctionAttributes, dontInferNothrowIn))); |
| 38 |
static assert(!isNothrow!(__traits(getFunctionAttributes, dontInferNothrowOut))); |