Some examples beyond that overused "list of things" example.
Some examples beyond that overused "list of things" example.
http://delphisorcery.blogspot.com/2014/10/the-real-power-of-generics.html
http://delphisorcery.blogspot.com/2014/10/the-real-power-of-generics.html
Here's something I toyed with, to avoid the overhead of the RTTI invoke method. Essentially reduces overhead to two virtual calls per invokation.
ReplyDeletevar
widget: TWidget;
f: RIFunc; // reference to function(const Instance): string;
name: string;
begin
widget := ...
f := RI.PropGetter('Name');
name := f(widget);
WriteLn(name);
end;
Can do regular methods too of course.
Anyway yea generics can be useful for more than containers :-)
Generics are great for aggregation too.
ReplyDelete