forked from changkun/modern-cpp-tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path2.12.external.template.cpp
More file actions
24 lines (20 loc) · 610 Bytes
/
2.12.external.template.cpp
File metadata and controls
24 lines (20 loc) · 610 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
//
// 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
}