Amir <a...@aavani.net> schrieb am So., 15. Apr. 2018, 23:51:

> Hi all,
>
>    Currently, FPC allows declaring objects as
> var
>    MyMap: specialize TFPGMap<AnsiString, MyData>;
>
> This is very nice feature since I do not need define every Map/List/etc
> as a  separate type.
>
> But to create MyMap object, one has to write something like:
>    MyMap := (specialize TFPGMap<AnsiString, MyData>).Create()
>
> Wondering if there is any shorter way to handle the objects'
> initialization, .e.g., something like
>    MyMap := auto.Create;
>

Just declare a type for the specialization:

=== code begin ===

type
  TMyDataMap = specialize TFPGMap<AnsiString, MyData>;

var
  MyData: TMyDataMap;
begin
  MyData := TMyDataMap.Create;
end.

=== code end ===

Regards,
Sven

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

Reply via email to