August 2012
Intermediate to advanced
976 pages
30h 17m
English
When we initialize or assign a function pointer (§ 6.7, p. 247) from a function template, the compiler uses the type of the pointer to deduce the template argument(s).
As an example, assume we have a function pointer that points to a function returning an int that takes two parameters, each of which is a reference to a const int. We can use that pointer to point to an instantiation of compare:
template <typename T> int compare(const T&, const T&);// pf1 points to the instantiation int compare(const int&, const int&)int (*pf1)(const int&, const int&) = compare;
The type of the parameters in pf1 ...
Read now
Unlock full access