C++ 11 Template ... 与Decltype 测试
2015-12-10 00:59
597 查看
#include <iostream> #include "string" using namespace std; template<typename T> void func_one(T& val) { cout << val << endl << "finished"; } //不可用 template< typename T, typename... Args> auto func_two(int index, T& val, const Args&... args) -> decltype(T) { static int curIndex = 0; if (curIndex == index) { return val; } else { return func_two<T,Args...>(index, args...); } } template<typename T,typename... Args> void func_one(T& val, const Args&... args) { cout << val << endl; cout << "Test:" << endl; func_test(args...); //func_one(args...); } void func_test(double d, int i, string str) { cout << d << endl << i << endl << str << endl; } int main() { int x; func_one("1",2.0f,3,"4"); cin>>x; return 0; }
有点晚了,Mark ~希望下次看到继续测试