首页 > 编程语言 > 详细

[C++] decltype(auto) C++ 11 feature

时间:2015-10-27 14:57:09      阅读:305      评论:0      收藏:0      [点我收藏+]

1
//C++ 11 feature 2 template <class T1, class T2> 3 auto getMultiply(T1 data1, T2 data2) -> decltype(data1*data2) 4 { 5 return data1*data2; 6 } 7 int main() 8 { 9 //cout << getResult<int>(3,3,4,5) << endl; 10 cout <<getMultiply(12.2, 13.3)<< endl; 11 cout << typeid(getMultiply(12.2, 13.3)).name() << endl; 12 system("pause"); 13 }
  • autoDeduce 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

原文:http://www.cnblogs.com/tianhangzhang/p/4913907.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!