“Binding” means associating names with properties. “Function binding” is to associate what function definition is linked with each function call.
a type qualifier is a keyword that is used to instruct the compiler that the type now qualified is special in some way.
In C++ there are 2 well-known qualifiers: const (including constexpr, etc.) and volatile. “cv-qualifier” is the term used to refer both as a whole.
Variadic functions are functions that take a variable number of arguments. We can implement such functions using C-style variadic functions or modern C++ variadic templates.
Template parameters can accept unbounded number of arguments of different types
void print() {} // overload defined as recursion base case when args is empty
template <typename T, typename Types...>
void print(T first_arg, Types... args) { // args is called function param pack
// do something...
print(args);
}
// print(2, 3.0, "a") -> print(3.0, "a") -> print("a") -> print() (stop!)
we can also define the recursion base case by declaring print with 1 dependent type only, thanks to resolution rule prioritizing templates without trailing param pack….
template <typename Types...>
void print(Types... args) {
func(args...); // expand to func(arg1, arg2, ..., argN);
}
since C++ 17, fold expression enables computing the result using a binary operator over all arguments in a param pack (with an optional init value!)
… op pack ⇒ (((arg1 op arg2) op arg 3) … op argN)
pack here is an expression that contains the unexpanded packinit op ... op pack ⇒ ((init op arg1) op arg2)…