forked from codenuri/TEMPLATE
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.cpp
More file actions
35 lines (29 loc) · 757 Bytes
/
Copy pathtemplate.cpp
File metadata and controls
35 lines (29 loc) · 757 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
25
26
27
28
29
30
31
32
33
34
35
/*
* HOME : ecourse.co.kr
* EMAIL : smkang @ codenuri.co.kr
* COURSENAME : C++ Template Programming
* MODULE : template.cpp
* Copyright (C) 2017 CODENURI Inc. All rights reserved.
*/
class Test
{
public:
template<typename T> static void f() {}
template<typename T> class Complex {};
};
template<typename T> typename T::template Complex<int> foo(T a) // T 는 Test
{
Test::f<int>(); // ok
T::f<int>(); // error. < 를 해석할수 없다.
T::template f<int>(); // ok
Test::Complex<int> c1; // ok.. Test의 선언을 조사할수 있다.
T::Complex<int> c2; // error.
T::template Complex<int> c3; // error.
typename T::template Complex<int> c4; // ok
return c4;
}
int main()
{
Test t;
foo(t);
}