#include <iostream>
#include <string>
using namespace std;
template<typename Function,class... Args>
inline auto FunWrapper(Function &&f, Args &&...args)->decltype(f(std::forward<Args>(args)...))
{
return f(std::forward<Args>(args)...);
}
void Test1()
{
cout << "Test" << endl;
}
int Test2()
{
return 5;
}
string Test3(string s1, string s2)
{
return s1 + s2;
}
int main(int argc,char* argv[])
{
FunWrapper(Test1);
cout << FunWrapper(Test2) << endl;
cout << FunWrapper(Test3,"My name is ","FYH ") << endl;
system("pause");
return 0;
}
万能函数模板
猜你喜欢
转载自blog.csdn.net/zzy1448331580/article/details/92423829
今日推荐
周排行