首页 > 其他 > 详细

integral_constant

时间:2020-01-17 13:49:04      阅读:110      评论:0      收藏:0      [点我收藏+]

#include <iostream>
#include <type_traits>

using namespace std;

//实现求阶乘
template<unsigned n>
struct fac : std::integral_constant<int, n*fac<n - 1>::value>{};
template<>
struct fac<0> : std::integral_constant<int, 1>{};


int main()
{
cout << fac<5>::value << endl;
return 0;
}

integral_constant

原文:https://www.cnblogs.com/xpylovely/p/12205375.html

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