MCPcopy Create free account
hub / github.com/CppCon/CppCon2020 / main

Function main

Presentations/back_to_basics_smart_pointers/SourceFiles/raii.cpp:17–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15};
16
17int main() {
18
19 std::cout << std::endl;
20
21 ResourceGuard resGuard1{"memoryBlock1"};
22
23 std::cout << "\nBefore local scope" << std::endl;
24 {
25 ResourceGuard resGuard2{"memoryBlock2"};
26 }
27 std::cout << "After local scope" << std::endl;
28
29 std::cout << std::endl;
30
31
32 std::cout << "\nBefore try-catch block" << std::endl;
33 try {
34 ResourceGuard resGuard3{"memoryBlock3"};
35 throw std::bad_alloc();
36 }
37 catch (std::bad_alloc& e) {
38 std::cout << e.what();
39 }
40 std::cout << "\nAfter try-catch block" << std::endl;
41
42 std::cout << std::endl;
43
44}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected