Recent

Author Topic: Set of Enum in generic  (Read 807 times)

Okoba

  • Hero Member
  • *****
  • Posts: 555
Set of Enum in generic
« on: October 01, 2023, 06:23:20 pm »
Is there a way to declare a new set of an enum in a generic function? This function only specializes with enum types and I do not want to make a set for each.
Code: Pascal  [Select][+][-]
  1. type
  2.   TEnum = (A, B, C);
  3.  
  4.   procedure Test<T>(E: T);
  5.   type
  6.     S1 = set of TEnum;
  7.     S2 = set of T; //Error
  8.   begin
  9.   end;  

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10550
  • Debugger - SynEdit - and more
    • wiki
Re: Set of Enum in generic
« Reply #1 on: October 01, 2023, 06:25:41 pm »
Maybe
Code: Pascal  [Select][+][-]
  1.         S2 = set of low(t)..high(t);

Okoba

  • Hero Member
  • *****
  • Posts: 555
Re: Set of Enum in generic
« Reply #2 on: October 01, 2023, 06:27:55 pm »
That works!
Should I report the first one as an issue?

Martin_fr

  • Administrator
  • Hero Member
  • *
  • Posts: 10550
  • Debugger - SynEdit - and more
    • wiki
Re: Set of Enum in generic
« Reply #3 on: October 01, 2023, 06:29:37 pm »
That works!
Should I report the first one as an issue?
Some one from the FPC team needs to judge that.

Okoba

  • Hero Member
  • *****
  • Posts: 555
Re: Set of Enum in generic
« Reply #4 on: October 01, 2023, 06:36:54 pm »

 

TinyPortal © 2005-2018