mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 21:21:48 +03:00
34 lines
741 B
D
34 lines
741 B
D
// https://issues.dlang.org/show_bug.cgi?id=23651
|
|
|
|
template isCallable(alias callable)
|
|
{
|
|
static if (is(typeof(&callable!())))
|
|
enum bool isCallable = isCallable!(typeof(&callable!()));
|
|
else
|
|
enum bool isCallable = true;
|
|
}
|
|
|
|
string foo();
|
|
|
|
template FunctionTypeOf(alias func)
|
|
if (isCallable!func)
|
|
{
|
|
alias FunctionTypeOf = typeof(foo);
|
|
}
|
|
|
|
template ReturnType(alias func)
|
|
{
|
|
static if (is(FunctionTypeOf!func R == return))
|
|
alias ReturnType = R;
|
|
}
|
|
|
|
template isAttrRange()
|
|
{
|
|
alias NameType = ReturnType!((string r) => r);
|
|
//pragma(msg, "isAttrRange ", NameType, " ", string);
|
|
static assert(is(NameType == string));
|
|
|
|
enum isAttrRange = is(NameType == string);
|
|
}
|
|
|
|
static assert(isAttrRange!());
|