Operator overloading inconsistency (= vs. <>)
Original Reporter info from Mantis: Lord Horazont
-
Reporter name: Jonas Schäfer
Original Reporter info from Mantis: Lord Horazont
- Reporter name: Jonas Schäfer
Description:
Hi all,
While trying to use the TFPGList with records, I noticed that this is currently not possible without hacking. The compiler will complain about a missing operator overload, which is related to the line 675 of fgl.pp (function TFPGList.IndexOf(const Item: T): Integer):
while (Result < FCount) and (PT(FList)[Result] <> Item) do
The overloading of the operator <> is not permitted though. You can only overload =, which is completely okay, as <> can be replaced by "not =". However, the compiler does not use the overloaded = operator and continues to complain (example attached).
I hackfixed it by replacing the <> with = and prepending the condition with a not. Although that should not be a long term solution, since this seems definetly like a compiler flaw for me.
Either the separate overloading of <> should be allowed or the compiler must use the inverted = operator.
greetings
Additional information:
Great work though. Generics continually make my day :)
Mantis conversion info:
- Mantis ID: 16641
- OS: linux
- OS Build: fedora 12
- Platform: x86_64
- Version: 2.4.0
- Monitored by: » Basil Peace (Basil Peace), » Hixie (Ian Hickson)