-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP177.ParameterizedDeclarations.cpp
More file actions
60 lines (50 loc) · 1.15 KB
/
Copy pathP177.ParameterizedDeclarations.cpp
File metadata and controls
60 lines (50 loc) · 1.15 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
// template declearations in namespace scope
// class template
template<typename T1, typename T2>
class Foo {};
// function template
template<typename T>
void foo()
{
std::cout << "template<typename T> void foo()" << std::endl;
}
// variable template
template<typename T>
int bar = 1;
// alias template
template<typename T>
using FooInt = Foo<int, T>;
// template declearations in class scope
class Buz
{
public:
// nested class template
template<typename T1, typename T2>
class Foo {};
// memeber function template
template<typename T>
void foo()
{
std::cout << "template<typename T> void Buz::foo()" << std::endl;
}
// static member variable template
template<typename T>
inline static int bar = 1;
// member alias template
template<typename T>
using FooInt = Foo<int, T>;
};
int main(int argc, char const *argv[])
{
Foo<int, double> f1;
foo<int>();
std::cout << bar<int> << std::endl;
FooInt<double> f2;
Buz buz;
Buz::Foo<int, double> bf1;
buz.foo<double>();
std::cout << Buz::bar<double> << std::endl;
Buz::FooInt<double> bf2;
return 0;
}