Reputation:
What is the difference between function template and template function?
Upvotes: 21
Views: 14329
Reputation: 23168
The term "function template" refers to a kind of template. The term "template function" is sometimes used to mean the same thing, and sometimes to mean a function instantiated from a function template. This ambiguity is best avoided by using "function template" for the former and something like "function template instance" or "instance of a function template" for the latter. Note that a function template is not a function. The same distinction applies to "class template" versus "template class".
Upvotes: 16
Reputation: 1
The function generated by the compiler from function template(generic function) for specified data type is known as template function. Example: The below code is called function template as it is template for a function.
template<T>
T doubleVal(T a){
return a+a;
}
int main(){
cout<<doubleVal<int>(5)<<endl;
}
When we compile this code compiler will write a function for int by taking reference from template function. That function is known as template function.
Upvotes: 0
Reputation: 25343
Function Template is the correct terminology (a template to instantiate functions from).
Template Function is a colloquial synonym.
So, there's no difference whatsoever.
Upvotes: 0