其他分享
首页 > 其他分享> > decltype有什么用

decltype有什么用

作者:互联网

简洁易懂讲清原理,讲不清你来打我~

当我们需要某个表达式的返回值类型又不想实际执行表达式时用decltype而不用auto

泛型编程中结合auto用于追踪函数返回值类型

template <typename T1, typename T2> auto multiply(T1 x, T2 y)->decltype(T1*T2){     return x*y; }

标签:decltype,auto,什么,T2,T1,返回值,表达式
来源: https://www.cnblogs.com/zhouzihong/p/15057981.html