mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-13 20:12:26 +00:00
21 lines
314 B
C++
21 lines
314 B
C++
// https://cirosantilli.com/linux-kernel-module-cheat#cpp-templates
|
|
|
|
#include <cassert>
|
|
|
|
template <class T>
|
|
struct MyClass {
|
|
static int i;
|
|
MyClass() {
|
|
i++;
|
|
}
|
|
};
|
|
|
|
template <class T>
|
|
int MyClass<T>::i = 0;
|
|
|
|
int main() {
|
|
MyClass<int>();
|
|
MyClass<int>();
|
|
assert(MyClass<int>::i == 2);
|
|
}
|