Recent

Author Topic: Call a template function  (Read 522 times)

LemonParty

  • Hero Member
  • *****
  • Posts: 562
Call a template function
« on: August 13, 2025, 07:46:33 pm »
Hello.
I have function
Code: Pascal  [Select][+][-]
  1. function FirstInSet<T{:set}>(aSet:T): SizeUInt; inline;
  2.  
I trying to call it this way:
Code: Pascal  [Select][+][-]
  1. FirstInSet(MySet);
And I getting error
Quote
Error: Wrong number of parameters specified for call to "FirstInSet"
What I doing wrong?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Warfley

  • Hero Member
  • *****
  • Posts: 2071
Re: Call a template function
« Reply #1 on: August 13, 2025, 08:26:03 pm »
In mode ObjFPC:
Code: Pascal  [Select][+][-]
  1. specialize FirstInSet<TMySetType>(MySet);
in mode Delphi
Code: Pascal  [Select][+][-]
  1. FirstInSet<TMySetType>(MySet);

LemonParty

  • Hero Member
  • *****
  • Posts: 562
Re: Call a template function
« Reply #2 on: August 13, 2025, 09:15:37 pm »
It works. Thank you.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

 

TinyPortal © 2005-2018