Skip to content

Commit 14b2363

Browse files
ntrelthewilsonator
authored andcommitted
[std.traits] Improve FunctionTypeOf docs
1 parent eeffdfe commit 14b2363

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

std/traits.d

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,7 +2181,7 @@ if (isCallable!func)
21812181

21822182

21832183
/**
2184-
Get the function type from a callable object `func`.
2184+
Get the function type from a callable object `func`, or from a function pointer/delegate type.
21852185
21862186
Using builtin `typeof` on a property function yields the types of the
21872187
property value, not of the property function itself. Still,
@@ -2229,10 +2229,17 @@ if (isCallable!func)
22292229
{
22302230
class C
22312231
{
2232-
int value() @property { return 0; }
2232+
int value() @property => 0;
2233+
static string opCall() => "hi";
22332234
}
22342235
static assert(is( typeof(C.value) == int ));
22352236
static assert(is( FunctionTypeOf!(C.value) == function ));
2237+
static assert(is( FunctionTypeOf!C == typeof(C.opCall) ));
2238+
2239+
int function() fp;
2240+
alias IntFn = int();
2241+
static assert(is( typeof(fp) == IntFn* ));
2242+
static assert(is( FunctionTypeOf!fp == IntFn ));
22362243
}
22372244

22382245
@system unittest

0 commit comments

Comments
 (0)