My omnium-gatherom of scripts and source code.
1#include <array>
2#include <iostream>
3#include <string>
4#include <vector>
5
6class Lifetime {
7 public:
8 Lifetime()
9 {
10 std::cout << "Lifetime() // default ctor\n";
11 }
12 ~Lifetime()
13 {
14 std::cout << "~Lifetime() // destructor\n";
15 }
16
17 Lifetime(int x) : member(x)
18 {
19 std::cout << "Lifetime(int) // ctor\n";
20 }
21
22 Lifetime(Lifetime const&)
23 {
24 std::cout << "Lifetime(Lifetime const&) // copy ctor\n";
25 }
26
27 Lifetime(Lifetime&&)
28 {
29 std::cout << "Lifetime(Lifetime &&) // move ctor\n";
30 }
31
32 auto operator=(Lifetime&&) -> Lifetime&
33 {
34 std::cout << "operator = (Lifetime &&) // move assign\n";
35 return *this;
36 }
37
38 auto operator=(Lifetime const&) -> Lifetime&
39 {
40 std::cout << "operator = (Lifetime const&) // copy assign\n";
41 return *this;
42 }
43
44 private:
45 int member;
46};
47
48auto main() noexcept -> int
49{
50 auto const l_arr = std::array<Lifetime, 2>{Lifetime(4), Lifetime(2)};
51 return 0;
52}