-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtempl.cpp
35 lines (28 loc) · 796 Bytes
/
templ.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <stdio.h>
// output:
// dmitry@t:~$ g++ templ.cpp -DPLATFORM= ; ./a.out
// common add
// dmitry@t:~$ g++ templ.cpp -DPLATFORM=arm ; ./a.out
// arm add
namespace project {
// arm/math.h
namespace arm {
template<typename T> inline void add_() {printf("arm T add\n");}
}
// math.h
template<typename T> inline void add_() {
// wonderfull code
printf("common T add\n");
// mode code
// even more code
} inline namespace PLATFORM {template<typename T> inline void add() {add_<T>();}}
template<typename T> inline void dot_() {
// wonderfull code
add<T>();
// this dot template function is a long one
} inline namespace PLATFORM {template<typename T> inline void dot() {dot_<T>();}}
}
int main() {
project::dot<int>();
return 1;
}