Einzelnen Beitrag anzeigen

Der schöne Günther
Online

Registriert seit: 6. Mär 2013
6.110 Beiträge
 
Delphi 10 Seattle Enterprise
 
#1

Typdefinition: Generics in Generics gehen nicht?

  Alt 8. Jan 2020, 11:04
Delphi-Version: 10 Seattle
Ich glaube der Covfefe ☕ war zu schwach und ich stehe auf dem Schlauch.

Warum geht folgendes nicht, bzw. was muss ich tun damit es geht?

Delphi-Quellcode:
uses
   System.SysUtils;

type
   Nullable<T> = record
      value: T;
      hasValue: Boolean;
   end;

   TStruct = record
      someFloat: Nullable<Single>;
   end;

   TMyObject = class(TObject) // E2564 Undefinierter Typ 'Nullable<T>'
      myStruct: Nullable<TStruct>;
   end;
Der Compiler nimmt die Definition für mein TMyObject nicht an.



Im Docwiki finde ich:
Zitat:
Generic types are instantiated by providing type arguments. In Delphi, you can use any type as a type argument except for the following: a static array, a short string, or a record type that (recursively) contains a field of one or more of these two types.

Geändert von Der schöne Günther ( 8. Jan 2020 um 11:11 Uhr)
  Mit Zitat antworten Zitat