This is a common pattern I’m finding when working with generics in FPC. In the 
example below there is an equals comparison that needs to be checked but for 
some types such as records there is no default operator overload so I need to 
add one for every record that will be specialized in the class.

Is there a way around this? I’d like to just skip the comparison for 
specialized types that can’t be compared if possible.

type
        generic TCollection<T> = class
                procedure AddValue (value: T);
        end;
        

procedure TCollection.AddValue (value: T);
begin
        // comparison operator doesn't exist for records so I get compiler 
errors if I specialize TCollection<> with a record type
        if value = T then
                ;
end;

Regards,
        Ryan Joseph

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to