首页 > 其他分享 >返回值类型后置

返回值类型后置

时间:2022-10-20 13:00:24浏览次数:49  
标签:return 后置 int auto add template 类型 返回值

转自: 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

相关文章