Advanced Function Techniques and Templates Terminology Reference

This reference provides an overview of function overloading and template terminology you'll encounter in this chapter. Use it as a quick lookup guide.

Function Overloading Basics

Term Definition Example
Function Overloading Defining multiple functions with same name but different parameters int add(int, int) and double add(double, double)
Overloaded Function One of several functions sharing the same name Each version of print() is an overloaded function
Function Signature Function's name and parameter types (not return type) void print(int) vs void print(std::string)
Overload Set All functions with the same name in a scope All versions of max() form an overload set

Overload Resolution

Term Definition Example
Overload Resolution Process of selecting best matching function Compiler choosing print(int) for print(5)
Exact Match Argument type perfectly matches parameter func(5) calling func(int)
Trivial Conversion Minor conversion like array to pointer Array name converting to pointer
Promotion Converting small integer types to int/double char to int in function call
Type Conversion Converting argument to different type int to double to match parameter
Ambiguous Match Multiple functions match equally well Compiler cannot choose between overloads

Overload Differentiation

Term Definition Example
Parameter Count Number of parameters in function func(int) vs func(int, int) differ
Parameter Type Type of each parameter func(int) vs func(double) differ
Parameter Order Sequence of parameter types func(int, double) vs func(double, int)
const Qualification Whether parameter is const func(int&) vs func(const int&) differ

Function Control

Term Definition Example
Deleted Function Function explicitly disabled using = delete void func(double) = delete;
Default Arguments Parameter values used when argument not provided void print(int x = 0)
Optional Parameter Parameter with default value Last parameters in function declaration
Required Parameter Parameter without default value Must be provided in function call

Template Basics

Term Definition Example
Function Template Blueprint for creating type-generic functions template<typename T> T max(T a, T b)
Template Parameter Placeholder type in template definition T in template<typename T>
Template Argument Actual type used when instantiating template int when calling max<int>(5, 10)
typename Keyword Declares template type parameter template<typename T>
class Keyword Alternative to typename for type parameters template<class T> (means same as typename)

Template Instantiation

Term Definition Example
Template Instantiation Creating concrete function from template Generating max<int> from max<T>
Implicit Instantiation Compiler creates instance from function call max(5, 10) creates max<int>
Explicit Instantiation Manually specifying template argument max<double>(5.0, 10.0)
Template Argument Deduction Compiler inferring template type from arguments Deducing int from max(5, 10)
Instantiation Point Where compiler generates template instance At point of first use

Multi-Type Templates

Term Definition Example
Multiple Template Parameters Template with more than one type parameter template<typename T, typename U>
Independent Type Parameters Each parameter can be different type T and U can be different types
Type Parameter List Comma-separated list of template parameters <typename T, typename U, typename V>

Non-Type Template Parameters

Term Definition Example
Non-Type Template Parameter Template parameter that is a value, not a type template<int N>
Compile-Time Constant Value known at compile time Literal or constexpr variable
Template Value Argument Actual value for non-type parameter 10 in array<int, 10>
Integral Constant Integer value used as template parameter template<int Size>

Template Organization

Term Definition Example
Template Definition Complete implementation of template Full template code with body
Header-Only Template Template defined entirely in header file Templates must be visible to compiler
Template Declaration Forward declaration of template (rarely used) template<typename T> T max(T, T);
Inline Expansion Template code inserted at call site Each instantiation generates new code

Template Constraints

Term Definition Example
Template Specialization Custom implementation for specific type Optimized version of max<bool>
Type Requirements What operations template expects on types Type T must support < operator
Concept Named set of requirements for template types C++20 feature for constraining templates
SFINAE Substitution Failure Is Not An Error Template resolution technique