diff options
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/user-guide/03-convenience-features.md | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/user-guide/03-convenience-features.md b/docs/user-guide/03-convenience-features.md index 559e4c9b4..1561d6605 100644 --- a/docs/user-guide/03-convenience-features.md +++ b/docs/user-guide/03-convenience-features.md @@ -331,6 +331,22 @@ int test() ``` Slang currently supports overloading the following operators: `+`, `-`, `*`, `/`, `%`, `&`, `|`, `<`, `>`, `<=`, `>=`, `==`, `!=`, unary `-`, `~` and `!`. Please note that the `&&` and `||` operators are not supported. +In addition, you can overload operator `()` as a member method: +```csharp +struct MyFunctor +{ + int operator()(float v) + { + // ... + } +} +void test() +{ + MyFunctor f; + int x = f(1.0f); // calls MyFunctor::operator(). + int y = f.operator()(1.0f); // explicitly calling operator(). +} +``` ## Subscript Operator |
