Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Test;
- {$APPTYPE CONSOLE}
- uses
- Generics.Defaults;
- type
- Op = record
- strict private type
- Comparer<T> = record
- class var comparer: IComparer<T>;
- class constructor Create;
- end;
- public
- class function InRange<T>(const AValue, AMin, AMax: T): Boolean; inline; static;
- end;
- class constructor Op.Comparer<T>.Create;
- begin
- comparer := TComparer<T>.Default;
- end;
- class function Op.InRange<T>(const AValue, AMin, AMax: T): Boolean;
- begin
- Result := (Comparer<T>.comparer.Compare(AValue, AMin) >= 0)
- and (Comparer<T>.comparer.Compare(AValue, AMax) <= 0);
- end;
- begin
- WriteLn(Op.InRange(0.5, 0.1, 1.0));
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement