- 新增现代 C++ 教程的 Preface 章节,包括英文和中文版本 - 添加 C++ Primer 练习代码 - 新增 Learn C++ 教程的 C++ 开发简介章节 - 添加头文件解析文档 - 更新 mkdocs.yml,包含新教程的目录结构 - 修改项目设置,使用 Python 3.10环境
24 lines
610 B
C++
24 lines
610 B
C++
//
|
|
// 2.12.external.template.cpp
|
|
// chapter 2 language usability
|
|
// modern cpp tutorial
|
|
//
|
|
// created by changkun at changkun.de
|
|
// https://github.com/changkun/modern-cpp-tutorial
|
|
//
|
|
|
|
#include <iostream>
|
|
#include <vector>
|
|
|
|
template class std::vector<bool>; // forcely instantiation
|
|
extern template class std::vector<double>; // external template for avoiding instantiation in this file
|
|
|
|
template<bool T> class MagicType {
|
|
bool magic = T;
|
|
};
|
|
|
|
int main() {
|
|
// the >> in template
|
|
std::vector<std::vector<int>> matrix;
|
|
std::vector<MagicType<(1>2)>> magic; // legal, but not recommended
|
|
} |