[fpc-devel] objfpc generics how to generate self type reference ?
Mattias Gaertner
nc-gaertnma at netcologne.de
Tue Sep 3 13:11:03 CEST 2019
On Tue, 3 Sep 2019 12:38:49 +0200
Mattias Gaertner via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
> On Tue, 3 Sep 2019 12:15:50 +0200
> Marco van de Voort <fpc at pascalprogramming.org> wrote:
>
> > I'm trying to let an iterator implement the enumerator pattern and
> > return itself, but for that I need to use the type of the generic:
> >
> > generic THashmapIterator<TKey, TValue, T, TTable>=class
> > public
> > type PValue=^TValue;
> >
> > // make type alias
> >
> > TIteratorType = generic THashmapIterator<TKey,
> > TValue, T, TTable>;
>
> Inside the generic the templates are normal types:
>
> TIteratorType = specialize THashmapIterator<TKey, TValue, T,
> TTable>;
Btw, mode objfpc allows shortcut THashmapIterator without <> as
shortcut for "specialize THashmapIterator<TKey, TValue, T, TTable>";
Mattias
More information about the fpc-devel
mailing list