Line |
Branch |
Exec |
Source |
1 |
|
|
#pragma once |
2 |
|
|
#include <iostream> |
3 |
|
|
|
4 |
|
|
namespace utils { |
5 |
|
|
template <typename Derived> |
6 |
|
|
class Lifetime { |
7 |
|
|
public: |
8 |
|
9 |
Lifetime() { std::cout << Derived::getName() << " constructed.\n"; } |
9 |
|
2 |
Lifetime(const Lifetime&) { |
10 |
|
2 |
std::cout << Derived::getName() << " copy-constructed.\n"; |
11 |
|
2 |
} |
12 |
|
2 |
Lifetime(Lifetime&&) { |
13 |
|
2 |
std::cout << Derived::getName() << " move-constructed.\n"; |
14 |
|
2 |
} |
15 |
|
1 |
Lifetime& operator=(const Lifetime&) { |
16 |
|
1 |
std::cout << Derived::getName() << " copy-assigned.\n"; |
17 |
|
1 |
return *this; |
18 |
|
|
} |
19 |
|
1 |
Lifetime& operator=(Lifetime&&) noexcept { |
20 |
|
1 |
std::cout << Derived::getName() << " move-assigned.\n"; |
21 |
|
1 |
return *this; |
22 |
|
|
} |
23 |
|
26 |
virtual ~Lifetime() { std::cout << Derived::getName() << " destroyed.\n"; }; |
24 |
|
|
}; |
25 |
|
|
} // namespace utils |
26 |
|
|
|