| 1 |
// https://issues.dlang.org/show_bug.cgi?id=23651 |
| 2 |
|
| 3 |
template isCallable(alias callable) |
| 4 |
{ |
| 5 |
static if (is(typeof(&callable!()))) |
| 6 |
enum bool isCallable = isCallable!(typeof(&callable!())); |
| 7 |
else |
| 8 |
enum bool isCallable = true; |
| 9 |
} |
| 10 |
|
| 11 |
string foo(); |
| 12 |
|
| 13 |
template FunctionTypeOf(alias func) |
| 14 |
if (isCallable!func) |
| 15 |
{ |
| 16 |
alias FunctionTypeOf = typeof(foo); |
| 17 |
} |
| 18 |
|
| 19 |
template ReturnType(alias func) |
| 20 |
{ |
| 21 |
static if (is(FunctionTypeOf!func R == return)) |
| 22 |
alias ReturnType = R; |
| 23 |
} |
| 24 |
|
| 25 |
template isAttrRange() |
| 26 |
{ |
| 27 |
alias NameType = ReturnType!((string r) => r); |
| 28 |
//pragma(msg, "isAttrRange ", NameType, " ", string); |
| 29 |
static assert(is(NameType == string)); |
| 30 |
|
| 31 |
enum isAttrRange = is(NameType == string); |
| 32 |
} |
| 33 |
|
| 34 |
static assert(isAttrRange!()); |