1 Star 0 Fork 2

movetoyushuiqiang / C++11实用新特性

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
返回值类型后置.cpp 424 Bytes
一键复制 编辑 原始数据 按行查看 历史
夜空中最亮的星 提交于 2022-02-10 06:11 . C++11返回值类型后置
#include <iostream>
using namespace std;
#include <string>
#include <list>
#include <map>
template<typename T, typename G>
auto add(T a, G b)->decltype(a + b)//返回值类型后置
{
return a + b;
}
int main()
{
//返回值类型后置一般用于泛型编程 在不知道模板是什么返回值的情况下可以用自动类型推导出来
int x = 520;
double y = 13.14;
auto ret = add<int, double>(x, y);
cout << ret << endl;
return 0;
}
C++
1
https://gitee.com/jackysq/C--11.git
git@gitee.com:jackysq/C--11.git
jackysq
C--11
C++11实用新特性
master

搜索帮助