函數包裝器

#include
template<typename T,typename F>
T run(T a, F f)
{
return f(a);
}
void main8()
{
using std::function;
double db = 12.9;
//       返回值(參數)
function<double(double)> fun1 = [](double u) {return u * 2; };
std::cout << run(db, fun1) << std::endl;
std::cin.get();
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章