material/program/c_cpp/STL/function.md
RongersLY 93cecd7544 BIG MERGE!!!
BIG ADD:
- docker
- archlinux

FIX:
- vim
- c_cpp
  - string hash
  - linux /dev/random
  - thread
  - STL
- linux
  - command
    - last

OTHERS:
- add antenna.md
- mirrors
- makefile.md
2025-04-04 17:35:35 +08:00

25 lines
450 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# function 包装器
提供更加一致的接口,避免多次实例化
对于调用特征标(call signature)一样的函数使用function进行包装
```cpp
std::function<double(int)> fun1;
```
+ 可接受任何函数指针函数对象lambda表达式
```cpp
template <typename T>
void print(T f, int a) {
std::cout << f(a) << std::endl;
}
double f1(int a) {
return a/1.0;
}
std::function<double(int)> fun1=f1;
print(fun1, 10);
```