[fpc-devel] [Feature Request] get nested type from a generic class

ZAN DoYe 1123monkey at gmail.com
Fri Sep 21 03:57:18 CEST 2012


I wanna make a generic class that can generates all six relational operators with the passed in  class T which has only one lessThan operator. But fpc can't recognize blow code:

     generic tLess<T>= class
         public type
             tT= T;
         public
             class function lessThan(const a, b: T): boolean;
     end;

     generic tCompOps<C>= class
         public type
             T= C.tT;                        //// Error: Error in type definition ////
         public
             class function equal(const a, b: T): boolean;
             class function notEqual(const a, b: T): boolean;
             class function lessThan(const a, b: T): boolean;
             class function lessThanOrEqual(const a, b: T): boolean;
             class function greaterThan(const a, b: T): boolean;
             class function greaterThanOrEqual(const a, b: T): boolean;
     end;

I hope this feature could be implemented if it's possible.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gUtils.pas
Type: text/x-pascal
Size: 2028 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20120921/7cde2e20/attachment.pas>


More information about the fpc-devel mailing list