Function passed as template argument
问题 I\'m looking for the rules involving passing C++ templates functions as arguments. This is supported by C++ as shown by an example here: #include <iostream> void add1(int &v) { v+=1; } void add2(int &v) { v+=2; } template <void (*T)(int &)> void doOperation() { int temp=0; T(temp); std::cout << \"Result is \" << temp << std::endl; } int main() { doOperation<add1>(); doOperation<add2>(); } Learning about this technique is difficult, however. Googling for \"function as a template argument\"