Recent

Author Topic: any workaround of nested generic  (Read 813 times)

powerpcer

  • Full Member
  • ***
  • Posts: 102
any workaround of nested generic
« on: September 26, 2023, 11:12:52 am »
i've container hashmap<TKEY,TVALUE>, vector<T> , point<T>;
but my algorithm need like this

generic aTree<T>=class
type
TPOINT=specialize point<T>;
TVEC=specialize vector<TPOINT>;
TTREEMAP=specialize hashmap<string,TVEC>; <--Error

it shows Error: Generics cannot be used as parameters when specializing generics

Leledumbo

  • Hero Member
  • *****
  • Posts: 8776
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: any workaround of nested generic
« Reply #1 on: September 27, 2023, 08:37:12 am »
Please post the full code, I can compile yours (with my own imagination of how point, vector and hashmap should be) even with 3.2.2.

Warfley

  • Hero Member
  • *****
  • Posts: 1762
Re: any workaround of nested generic
« Reply #2 on: September 27, 2023, 10:48:23 am »
Works without any problem:
Code: Pascal  [Select][+][-]
  1. type
  2.   generic point<T>=record
  3.   end;
  4.   generic vector<T>=record
  5.   end;
  6.   generic hashmap<T,U>=class
  7.   end;
  8.  
  9.   generic aTree<T>=class
  10.   public type
  11.     TPOINT=specialize point<T>;
  12.     TVEC=specialize vector<TPOINT>;
  13.     TTREEMAP=specialize hashmap<string,TVEC>;
  14.   end;
  15.  
  16.   TIntTree = specialize aTree<Integer>;
« Last Edit: September 27, 2023, 10:50:05 am by Warfley »

 

TinyPortal © 2005-2018