Needed a TEmpty to turn a TPair back into a TSingle

Needed a TEmpty to turn a TPair<> back into a TSingle<> 

I've made some generic trees and like so:

type
  TBaseTree = class
  TBaseTree = class(TBaseTree)
  TBSTTree = class(TBaseTree)
  TBSTTree = class(TBaseTree)

However this creates duplication because I cannot have a single hierarchy. 

When I define a TEmpty like so:

type
  TEmpty = record
    class operator Implicit(a: pointer): TEmpty; inline;
    class operator Implicit(a: TEmpty): pointer; inline;
    class operator Implicit(a: TEmpty): string; inline;
  end;

  TEmpty = record
  public type
    PT = ^T;
  public
    class operator Implicit(a: PT): TEmpty; inline;
    class operator Implicit(a: TEmpty): PT; inline;
    class operator Implicit(a: TEmpty): string; inline;
    class operator Implicit(a: TEmpty): T; inline;
  end;

I can say:
type
  TBSTTree = TBinaryTree

Allowing me to have a single hierarchy and reuse more code. 

What do you think?

Comments