-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathExceptionSafety.cpp
More file actions
44 lines (34 loc) · 1.14 KB
/
ExceptionSafety.cpp
File metadata and controls
44 lines (34 loc) · 1.14 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
// =====================================================================================
// ExceptionSafety.cpp // Exception Safety
// =====================================================================================
module modern_cpp:exception_safety;
namespace ExceptionSafety {
class TwoPointers
{
private:
std::unique_ptr<int> m_pi;
std::unique_ptr<double> m_pd;
public:
TwoPointers(int* pi, double* pd)
: m_pi{ pi }, m_pd{ pd }
{}
};
static void test_exception_safety()
{
TwoPointers tp { new int(123), new double(123.456) };
}
class StrongExceptionSafety {
StrongExceptionSafety& operator= (const StrongExceptionSafety& other) {
StrongExceptionSafety temp{ other };
temp.swap(*this);
return *this;
}
void swap(StrongExceptionSafety& other) noexcept {}
};
}
void main_exception_safety()
{
}
// =====================================================================================
// End-of-File
// =====================================================================================