模板元编程加速递归
来源:互联网 发布:淘宝 钥匙书签 编辑:程序博客网 时间:2024/06/06 13:04
//模板元编程加速递归
//缺点:模板元在编译时处理,无法调试,并且会加大代码体积
#include<iostream>
using namespace std;
template <int N>
struct data
{
enum{res = data<N - 1>::res + data<N - 2>::res};
};
template <>//模板具体化
struct data<1>
{
enum{res = 1};
};
template <>
struct data<2>
{
enum{res = 1};
};
int main()
{
cout << data<40>::res << endl;
return 0;
}
//缺点:模板元在编译时处理,无法调试,并且会加大代码体积
#include<iostream>
using namespace std;
template <int N>
struct data
{
enum{res = data<N - 1>::res + data<N - 2>::res};
};
template <>//模板具体化
struct data<1>
{
enum{res = 1};
};
template <>
struct data<2>
{
enum{res = 1};
};
int main()
{
cout << data<40>::res << endl;
return 0;
}
0 0
- 模板元编程加速递归
- 模板元编程递归解析
- 模板元编程实现递归
- C++模板元编程之模板递归
- C++模板元编程(递归-->分解)
- C++模板元编程(递归-->分解)
- 模板--模板元编程
- 初探模板元编程
- 模板元编程
- C++模板元编程
- 模板元编程
- 模板元编程
- C++模板元编程
- C++模板元编程
- 模板元编程-C++
- C++模板元编程
- 模板元编程(二)
- 模板元编程练习
- 字符编码
- android开发异常总结
- Git使用入门,使用原理解读及如何在GitLab、GitHub或者Stash上管理项目(二)
- Eclipse插件9
- 前端大全—总结css选择器知识
- 模板元编程加速递归
- 字符数组,特殊的数组
- Eclipse插件10
- 数据可视化是如何被创造出来的
- Centos 6.6命令行实现自动补全
- 在online judge中建立简单数据结构,简单高效处理
- Xcode6模拟器路径变更说明
- 10个Eclipse调试技巧
- org.apache.ibatis.builder.IncompleteElementException: Could not find result map