Special cases in C++ program
来源:互联网 发布:m4螺纹编程 编辑:程序博客网 时间:2024/05/16 15:14
Recently, I have accepted the challenge to read code in a github repository called mshadow. But only from the language grammar. I found that I could not understand template<> in the code.
So what I do is to search it from internet. And this is what I found. Try to understand the following codes.
1. Template <>
template <int N>struct Factorial{ enum { value = N * Factorial<N - 1>::value };};//reconstrunction???template <>struct Factorial<0>{ enum { value = 1 };};template <int N>struct Test{ int value = N+1;};template<>struct Test<0>{ int a = 0+2;};
The first structure is Factorial, but since it is recursive, so we need to define the seed-- from where to start. We use
template <>struct Factorial<0>It means that there only has one structure, if N is not 0, use the first definition of this structure, if it is 0, use the second part of this structure.
This way, it is easy to understand the second template called Test here.
2. To be continued.
0 0
- Special cases in C++ program
- some special cases of "extern" in C
- some cases about "const" in C Program
- Memory partition in C program
- lseek() sample program in C
- building c program with libsocket in ubuntu
- Number Comparison Program in Java & C
- Segmentation fault in c program runtime
- [线性常微分方程][5]SPECIAL CASES REPEATED AND ZERO EIGENVALUES
- TestNG Priority in Test Cases
- Special Characters in ToolTip
- Special Stocks in SAP
- Special issues in Android
- Special Commands in Doxygen
- Error running paycenter: Cannot run program "C:\Program Files" (in directory "C:\"): CreateProcess e
- Use Cases: Requirements in Context, Second Edition
- Use Cases in an Agile Backlog
- Agile Use Cases in Four Steps
- Two Sum
- 无聊下了个软件,然后做了个注册机
- Shortest Word Distance
- 运行shell脚本提示找不到该文件的错误,解决办法
- 使用notePad++添加sql引号
- Special cases in C++ program
- 5.5.3 顶点索引
- Shortest Word Distance II
- Shortest Word Dsitance III
- 字符编码
- 关于NGUI中一些控件的说明
- 百度2012校园招聘Java部分
- 从头认识java-8.9 嵌套类(使用static的内部类)
- homebrew下载安装及mysql的下载安装