|
RAD Studio (Common)
|
Generic methods can participate in overloading alongside non-generic methods by using the 'overload' directive. If overload selection between a generic method and a non-generic method would otherwise be ambiguous, the compiler selects the non-generic method.
For example:
type
TFoo = class
procedure Proc<T>(A: T);
procedure Proc(A: String);
procedure Test;
end;
procedure TFoo.Test;
begin
Proc('Hello'); // calls Proc(A: String);
Proc<String>('Hello'); // calls Proc<T>(A: T);
end;Two non-instantiated generics are considered assignment compatible only if they are identical or are aliases to a common type.
Two instantiated generics are considered assignment compatible if the base types are identical (or are aliases to a common type) and the type arguments are identical.
|
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
|
What do you think about this topic? Send feedback!
|