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. python中format函数学习笔记

    简而言之,format函数就是用{}来代替之前的输出字符时使用的% print('my name is %s and I am %d years old' % ('porsche',23)) 下面详细 ...

  2. 求助OPC Opc.IDiscovery m_discovery = new OpcCom.ServerEnumerator();

    各位大哥们,大家好,在此请教各位一个问题,谢谢大家.我在vs2010中引用了OpcNetApi.dll和OpcNetCom.dll并且加入了using Opc;using Opc.Da;using O ...

  3. SQL 只取重复记录一条记录并且是最小值

    and not exists( and a.StateValue>StateValue ) '

  4. 1123 Is It a Complete AVL Tree

    1123 Is It a Complete AVL Tree(30 分) An AVL tree is a self-balancing binary search tree. In an AVL t ...

  5. 安装Elastix-2.4版本

    首先,下载Elastix地址:http://www.elastix.org,下载里面的2.4版本 第一步:选择安装,Enter 选择语言,默认就行 选择us,默认 选择全部 选择默认分区,点击OK 配 ...

  6. golang的吐槽

    烂到极致的包管理:简单清晰的包管理机制是任何一门语言都需要具备的.后起之秀的golang,在众多成熟的其他语言包管理方式,居然做成这样,简直人间地狱.

  7. AtomicHashMap

    folly/AtomicHashmap.h folly/AtomicHashmap.h introduces a synchronized UnorderedAssociativeContainer ...

  8. 利用百度API(JavaScript 版)实现在地图上绘制任一多边形,并判断给定经纬度是否在多边形范围内。以及两点间的测距功能

    权声明:本文为博主原创文章,未经博主允许不得转载. 利用百度API(JavaScript 版)实现在地图上绘制任一多边形,并判断给定经纬度是否在多边形范围内.以及两点间的测距功能. 绘制多边形(蓝色) ...

  9. length length()

    数组长度 length String 长度 length()

  10. A start job is running for /etc/rc.d/rc.local ... ... no limit

    /etc/rc.d/rc.local文件中配置了redis随机启动但是没有设置redis启动为守护进程(daemonize yes)导致redis启动后阻塞