title: How to pass a TComparer<T> class to a generic type in Delphi?
body: <p>I want to create a generic record with some functionality, including a search function. 
  To perform this search I wanted to pass a custom Comparer to compare items.
  If it were a class, I could pass it in the constructor, but I want to use a record to avoid to create or free it. So, I don't have a constructor where to initialize the Comparer.</p>
  
  <p>Then I decided to pass the Comparer class like a Type parameter, and when I need the comparer, create a instance of the comparer using TComparer.Default.</p>
  
  <p>Well, here is the code:</p>
  
  <pre><code>TMyArray&lt;T,C: TComparer&lt;T&gt;&gt; = record
    FComparer: IComparer&lt;T&gt;;
    Items: TArray&lt;T&gt;;
  
    function Contains&lt;AItem: T&gt;: Boolean;
  end;
  </code></pre>
  
  <p>The problem appears when I try to use it in this way:</p>
  
  <pre><code>TMyRecord = record
    Score: Real;
    A: string;
    B: string;
  end;
  
  TMyRecordComparer = class(TComparer&lt;TMyRecord&gt;)
    function Compare(Left, Right: TMyRecord): Integer;
  end;
  
  TMyRecordArray = TMyArray&lt;TMyRecord, TMyRecordComparer&gt;;  
  </code></pre>
  
  <p>With this last declaration, I get this error:
  E2515 Type parameter 'T' is not compatible with type 'System.Generics.Defaults.TComparer\'.</p>
  
  <p>Any idea how to solve this issue?</p>