Author Topic: [Solved]problems with generics subclassing filtered types  (Read 170 times)

jamie

  • Hero Member
  • *****
  • Posts: 8029
[Solved]problems with generics subclassing filtered types
« on: October 01, 2026, 12:32:19 pm »
I have this
Code: Pascal  [Select][+][-]
  1. TnewMapObject<Tkey, TData:TObject> =Class(TFPGMapObject<TKey,TData>)
  2. ......
  3. End;
  4.  
  5.  
This of course uses the fgl unit
what happens is <Tkey,Tdata:TObject>... makes both Tkey and TData both Tobject filtered but I only want TData to be TOBJECT specific

How to solve this ?

Jamie
« Last Edit: October 03, 2026, 11:52:35 pm by jamie »
The only true wisdom is knowing you know nothing

H₂SO₄

  • Hero Member
  • *****
  • Posts: 511
Re: problems with generics subclassing filtered types
« Reply #1 on: October 01, 2026, 01:24:32 pm »
Generic template lists actually use semicolons as the separator (just like function parameters):

Code: Pascal  [Select][+][-]
  1. TNewMapObject<TKey; TData: TObject> = class(TFPGMapObject<TKey, TData>)

jamie

  • Hero Member
  • *****
  • Posts: 8029
Re: problems with generics subclassing filtered types
« Reply #2 on: October 02, 2026, 12:20:53 am »
Apparently, that was the problem however, I did try that before and was running into problems that really had nothing to do with the filtering of the types but was affecting my attempt to correct something.

I now have a fully working TFPGMapEx and TFPGMapObjectEx that has a TMapPair for each that can be used as an enumerator for the map.

If anyone wants a copy of my generics unit file I can post is here. It piggy backs off of FGL code.


Thank You.


The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018