#include <functional>
#include <type_traits>
#include <memory>
#include <iostream>
int TestFuncInt(int &a ) {
return 16;
}
int main(){
std::shared_ptr<std::function<int(int&)>> AF = std::make_shared<std::function<int(int&)>>(TestFuncInt);
// 第一种构造方法
//std::shared_ptr<std::function<int(int&)>> AF2 = std::move(AF); // AF 地址变成0
//第二种赋值方法 ()
//std::shared_ptr<std::function<int(int&)>> AF2 = AF; AF 和AF2 地址相同
// 第二种构造方法
std::shared_ptr<std::function<int(int&)>> AF2 = std::make_shared<std::function<int(int&)>>(std::forward<
std::function<int(int&)>>(*AF));
}
关于右值完美转发请参考:https://blog.csdn.net/TH_NUM/article/details/90582674