diff options
Diffstat (limited to 'libphobos/src/std/traits.d')
-rw-r--r-- | libphobos/src/std/traits.d | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libphobos/src/std/traits.d b/libphobos/src/std/traits.d index 2e7a4f6..5ed37a1 100644 --- a/libphobos/src/std/traits.d +++ b/libphobos/src/std/traits.d @@ -2181,7 +2181,7 @@ if (isCallable!func) /** -Get the function type from a callable object `func`. +Get the function type from a callable object `func`, or from a function pointer/delegate type. Using builtin `typeof` on a property function yields the types of the property value, not of the property function itself. Still, @@ -2229,10 +2229,17 @@ if (isCallable!func) { class C { - int value() @property { return 0; } + int value() @property => 0; + static string opCall() => "hi"; } static assert(is( typeof(C.value) == int )); static assert(is( FunctionTypeOf!(C.value) == function )); + static assert(is( FunctionTypeOf!C == typeof(C.opCall) )); + + int function() fp; + alias IntFn = int(); + static assert(is( typeof(fp) == IntFn* )); + static assert(is( FunctionTypeOf!fp == IntFn )); } @system unittest |