templatefunctionaddress.cpp

来自「很经典的书籍」· C++ 代码 · 共 24 行

CPP
24
字号
//: C05:TemplateFunctionAddress.cpp
// Taking the address of a function generated
// from a template.

template <typename T> void f(T*) {}

void h(void (*pf)(int*)) {}

template <typename T>
  void g(void (*pf)(T*)) {}

int main() {
  // Full type specification:
  h(&f<int>);
  // Type deduction:
  h(&f);
  // Full type specification:
  g<int>(&f<int>);
  // Type deduction:
  g(&f<int>);
  // Partial (but sufficient) specification
  g<int>(&f);
} ///:~

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?