1 //C++ 11 feature
template <class T1, class T2>
auto getMultiply(T1 data1, T2 data2) -> decltype(data1*data2)
{
return data1*data2;
}
int main()
{
//cout << getResult<int>(3,3,4,5) << endl;
cout <<getMultiply(12.2, 13.3)<< endl;
cout << typeid(getMultiply(12.2, 13.3)).name() << endl;
system("pause");
}
  • auto : Deduce the type of data based on actual data
  • auto is not allowed  to be used  as a function parameter

[C++] decltype(auto) C++ 11 feature的更多相关文章

  1. c++11-17 模板核心知识(九)—— 理解decltype与decltype(auto)

    decltype介绍 为什么需要decltype decltype(auto) 注意(entity) 与模板参数推导和auto推导一样,decltype的结果大多数情况下是正常的,但是也有少部分情况是 ...

  2. auto 和 decltype (C++11 新增)

    红色字体为个人推断,可信度自辨. 蓝色字体为重点. auto类型说明符:使用auto时,编译器会分析表达式,并自动推算出变量所属类型.*auto变量必须有初值 原理:编译器通过 初值 来判断auto变 ...

  3. auto和decltype(c++11)

    1.auto 1)auto是一个类型说明符(类型说明符就是像int.double这样的),用来定义一个变量,它可以让编译器去分析表达式的类型,并使用该表达式的值去初始化变量 //auto定义的变量必须 ...

  4. opatch auto 安装11.2.0.4.20190115 PSU遇到 OUI-67133: Execution of PRE script failed,with returen value 1 报错

    AIX 7.2 下Oracle 11.2.0.4  RAC数据库root用户在使用 /u01/app/11.2.0/grid/OPatch/opatch auto /soft/28813878 -oc ...

  5. auto(c++11)

    C++primer 第五版,第三章出现了此段程序,求解读附源码:代码1:#include<iostream>#include<string>using namespace st ...

  6. C++11 feature: move constructor

    There are heaps of good articles out there about C++ features including this move constructor. Howev ...

  7. C++ 11常见功能介绍:auto,decltype,nullptr,for,lambda

    什么是C++11 C++11是曾经被叫做C++0x,是对目前C++语言的扩展和修正,C++11不仅包含核心语言的新机能,而且扩展了C++的标准程序库(STL),并入了大部分的C++ Technical ...

  8. C++11中decltype的使用

    The decltype type specifier yields the type of a specified expression. The decltype type specifier, ...

  9. c++11 之 decltype

    在C++中,decltype作为操作符,用于查询表达式的数据类型.decltype在C++11标准制定时引入,主要是为泛型编程而设计,以解决泛型编程中,由于有些类型由模板参数决定,而难以(甚至不可能) ...

随机推荐

  1. sphinx-1.3.0扩展在pPHP 7.0.7版本编译不通过

    在这个网友也是在php7上面编译插件不通过 https://bugs.php.net/bug.php?id=71586 下php7对应的扩展文件即可 http://git.php.net/?p=pec ...

  2. websphere删除概要文件(profiles)的方式

    [b]删除概要文件:[/b]方案一:1.找到profileRegistry.xml,在目录IBM\WebSphere\AppServer\properties里,去掉想删除的profile的配置即可. ...

  3. 1DAY 初识Python

    一 本节目标 了解编程语言 了解python及与其他语言的优劣对比 安装python解释器及环境变量配置.运行python交互式环境 打印hello world程序 初识变量.用户输入,流程控制,wh ...

  4. 数据结构与算法JavaScript描述——使用队列

    1.使用队列:方块舞的舞伴分配问题 前面我们提到过,经常用队列模拟排队的人.下面我们使用队列来模拟跳方块舞的人.当 男男女女来到舞池,他们按照自己的性别排成两队.当舞池中有地方空出来时,选两个队 列中 ...

  5. PS1 长命令回到行首进行覆盖

    linux shell 命令输入过长导致折行后的命令回到行首进行覆盖,第二行的时候又能自动换到下一行了,导致这个问题的原因是没有设置正确的 PS1 变量 家目录下打开 vim .bashrc 修改 P ...

  6. 关于最大传输单元(MTU)的整理

    MTU设置不当,可能会导致许多网络问题,如某些网络应用无法使用,某些网站无法访问等.下面是在网上搜索整理的关于MTU设置的东西,某些可能未作验证,仅供参考. 1. 如何确定网络MTU 某些ISP接入的 ...

  7. 【UVA】12504 Updating a Dictionary(STL)

    题目 题目     分析 第一次用stringstream,真TMD的好用     代码 #include <bits/stdc++.h> using namespace std; int ...

  8. python读取excel表格中的数据

    使用python语言实现Excel 表格中的数据读取,需要用到xlrd.py模块,实现程序如下: import xlrd #导入xlrd模块 class ExcelData(): def __init ...

  9. keil里面填数据

    编译后寄存器和堆栈的内存数据可以直接写进去的. 寄存器,双击就可以,注意里面是十六进制 堆栈,也是十六进制,八位的 00 00 00 00 ,但这个是从右到左的,比如0x00000006 应该填 06 ...

  10. C# WinForm ProgressBar垂直显示进度和从右向左显示进度

    1. 尝试将ProgressBar的RightToLeft属性设置为System.Windows.Forms.RightToLeft.Yes,同时将RightToLeftLayout属性设置为true ...