[fpc-pascal] Printing types in generics

Sven Barth pascaldragon at googlemail.com
Thu Oct 19 11:21:37 CEST 2017


Am 19.10.2017 08:41 schrieb "Ryan Joseph" <ryan at thealchemistguild.com>:
>
>
>
> > On Oct 19, 2017, at 12:58 PM, Sven Barth via fpc-pascal <
fpc-pascal at lists.freepascal.org> wrote:
> >
> > And your case for tkSString crashes, because that is a ShortString, not
a AnsiString thus you need to cast to PShortString (best avoid "(P)String"
in this context as this could lead to different results depending on the
modeswitches). For the other string types you need to look at tkAString
(AnsiString), tkWString (WideString) and tkUString (UnicodeString).
> >
>
> I know why it crashes at least. Thanks.

You're welcome. :)

> Btw why can’t type helpers be used here? I though you could add those and
just call .Show() or something but I couldn’t figure that out.

You'd need a type helper for every type that you might specialize with and
all those would need to be in scope during the declaration (not
specialization!) of your generic as otherwise they wouldn't be found during
specialization.

Regards,
Sven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20171019/981e4791/attachment.html>


More information about the fpc-pascal mailing list