转自: https://blog.csdn.net/m0_51955470/article/details/117960694
#include <iostream> using namespace std; //template<typename R,typename T,typename U> //R add01(T t, U u) //{ // return t + u; //} template <typename T, typename U> auto add(T t, U u)->decltype(t + u) { return t + u; } int main() { int x = 520; double y = 13.14; auto ret = add<int, double>(x, y); auto ret01 = add(x, y); cout << ret << endl; cout << ret01 << endl; return 0; }
标签:return,后置,int,auto,add,template,类型,返回值 From: https://www.cnblogs.com/5free/p/16809500.html