1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: implement > and < for structs (#7774)

This commit is contained in:
Swastik Baranwal
2021-01-01 19:24:32 +05:30
committed by GitHub
parent d15d13674c
commit 24b18f05c4
10 changed files with 53 additions and 23 deletions

View File

@ -3148,9 +3148,11 @@ operator overloading is an important feature to have in order to improve readabi
To improve safety and maintainability, operator overloading is limited:
- It's only possible to overload `+, -, *, /, %` operators.
- It's only possible to overload `+, -, *, /, %, <, >` operators.
- `==` and `!=` are self generated by the compiler.
- Calling other functions inside operator functions is not allowed.
- Operator functions can't modify their arguments.
- When using `<` and `>`, the return type must be `bool`.
- Both arguments must have the same type (just like with all operators in V).
## Inline assembly