> Is there a way to have a single implementation of Enum-to-String or > Set-to-String (and the reverse), but pass in the type, instead of having > a separate implementation of each Enum or Set types. > > Could RTTI help? Could Generics help? Is there some other language > construct I might have missed?
Take mine: generic function EnumValueNameOf<T>(v: T): String; begin Result := GetEnumName(TypeInfo(T), LongInt(v)); end; guess you already know how to use it, don't you? -- View this message in context: http://free-pascal-general.1045716.n5.nabble.com/generic-way-of-writing-Sets-or-Enum-values-to-a-String-tp5726280p5726281.html Sent from the Free Pascal - General mailing list archive at Nabble.com. _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal