Jump to content
Sign in to follow this  
Wak

Generic pointer type to a generic type

Recommended Posts

I've worked with generics quite a bit, but I have never tried to define a generic pointer type to another generic type:

  TMyType<T> = record
    ID: T;
  end;

  PMyType<T> = ^TMyType<T>;            // Error: E2508 type parameters not allowed on this type
  TMyTypes<T> = array of TMyType<T>;   // OK
  PMyTypes<T> = array of ^TMyType<T>;  // OK

  TMyTypeHack<T> = record
    P: ^TMyType<T>;                    // OK
  end;

This raises a compiler error. It seems Delphi doesn't allow type aliases like this, but allows using them in the definition of array/record types. Has anyone found a trick to achieve it? Thanks!

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×