[fpc-pascal] Constants in generics

Maciej Izak hnb.code at gmail.com
Sun Apr 9 13:13:27 CEST 2017


2017-04-09 5:18 GMT+02:00 Ryan Joseph <ryan at thealchemistguild.com>:

> Is there anyway to make constants work in generics?


sure, but not directly. Try this:

=== code begin ===
{$MODE DELPHI}

type
  TA = record
  public const
    L = 16;
  end;

  TB<T, L> = record
  public type
    FData = array[0..L.L] of T;
  end;

var
  X: TB<Integer, TA>;

=== code end ===

-- 
Best regards,
Maciej Izak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20170409/7ab4d5c8/attachment.html>


More information about the fpc-pascal mailing list