Is there a compiler intrinsic to get the element type of a set at compile time? So if you have “set of T” it should return T.
Regards,
Ryan Joseph

Mailing lists / fpc-pascal / 2022-05
6 messages · 4 people ·
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Is there a compiler intrinsic to get the element type of a set at compile time? So if you have “set of T” it should return T.
Regards,
Ryan Joseph
Hairy Pixels wroteIs there a compiler intrinsic to get the element type of a set at compile time? So if you have “set of T” it should return T.
I don't think you can make such an intrinsic.
This type does not always exist, since you can define
Type
TMySet = set of (one,two,three);The element type does not exist as a separate type.
Michael.
I mean if you had code like this T would be the anonymous enum (one,two,three). Maybe element is not the correct term here but the type which is the enum in the set.
var
I: ElementType(TMySet);
begin
for i := low(TMySet) to high(TMySet) do
;Regards,
Ryan Joseph
I don't think you can make such an intrinsic. This type does not always exist, since you…
On Sun, 15 May 2022 09:03:58 +0200 (CEST)
Michael Van Canneyt via fpc-pascal
The RTTI supports it, so it always exists.
Mattias
I mean if you had code like this T would be the anonymous enum (one,two,three). Maybe…
type
TMySet = set of (one,two,three);
var
I: low(TMySet) .. high(TMySet) ;
begin
for i := low(TMySet) to high(TMySet) do
;type
TMySet=set of (one,two,three);
var
I:low(TMySet)..high(TMySet);
begin
for i:=low(TMySet) to high(TMySet) do
writeln(i);
end.prints indeed
one
two
three
Michael.