tw38145a.pp 513 B

1234567891011121314151617181920212223242526272829
  1. { %NORUN }
  2. program tw38145a;
  3. {$mode delphi}
  4. type
  5. TMyWrap<T> = record
  6. Value: T;
  7. class operator Explicit(const w: TMyWrap<T>): T;
  8. class operator Implicit(const w: TMyWrap<T>): T;
  9. end;
  10. class operator TMyWrap<T>.Explicit(const w: TMyWrap<T>): T;
  11. begin
  12. Result := w.Value;
  13. end;
  14. class operator TMyWrap<T>.Implicit(const w: TMyWrap<T>): T;
  15. begin
  16. Result := w.Value;
  17. end;
  18. type
  19. //TString = string[255]; //compiles
  20. TString = string[254]; //not compiles
  21. var
  22. MySpec: TMyWrap<TString>;
  23. begin
  24. end.