Skip to content

Commit b5ffdb4

Browse files
committed
test06.cpp
1 parent b76957a commit b5ffdb4

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

section2/test06.cpp

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,11 @@
77
#include <iostream>
88
#include <string>
99
#include <vector>
10+
#include <set>
1011
#include <map>
1112

13+
#include <signal.h>
14+
1215
void case1()
1316
{
1417

@@ -73,6 +76,37 @@ void case4()
7376
}
7477

7578
void case5()
79+
{
80+
int x = 0;
81+
82+
decltype(x) x1;
83+
decltype(x)& x2 = x;
84+
decltype(x)* x3;
85+
decltype(&x) x4;
86+
decltype(&x)* x5;
87+
decltype(x2) x6 = x2;
88+
89+
using int_ptr = decltype(&x);
90+
using int_ref = decltype(x)&;
91+
}
92+
93+
void case6()
94+
{
95+
int x = 0;
96+
97+
decltype(auto) x1 = (x);
98+
decltype(auto) x2 = &x;
99+
decltype(auto) x3 = x1;
100+
}
101+
102+
auto get_a_set()
103+
{
104+
std::set<int> s = {1,2,3};
105+
106+
return s;
107+
}
108+
109+
void case7()
76110
{
77111
using namespace std;
78112

@@ -90,6 +124,19 @@ void case5()
90124
cout << endl;
91125
}
92126

127+
class DemoClass final
128+
{
129+
public:
130+
using sig_func_ptr_t = decltype(&signal) ;
131+
public:
132+
using set_type = std::set<int>;
133+
134+
private:
135+
set_type m_set;
136+
137+
using iter_type = decltype(m_set.begin());
138+
iter_type m_pos;
139+
};
93140

94141
int main()
95142
{
@@ -100,6 +147,8 @@ int main()
100147
case3();
101148
case4();
102149
case5();
150+
case6();
151+
case7();
103152

104153
cout << "auto/decltype demo" << endl;
105154
}

0 commit comments

Comments
 (0)