Skip to content
← All tracks

RAII: Objects With Lifetimes

C++

The one idea. Smart pointers, locks, exception safety and the rule of zero are all this wearing a different hat, which is why it comes before any of them.

This track is written for C++, which isn't the mode you're browsing in.

0 / 4 solved
  1. 1. Not solved yet. The destructor is the whole idea
  2. 2. Not solved yet. Write the guard yourself
  3. 3. Not solved yet. The delete you will forget
  4. 4. Not solved yet. Exception safety you did not have to write

Check yourself

4 questions · one attempt each

These do not count toward finishing the track. They are here to catch the things that are easy to read past.

0 / 4

Two elements are emplaced into a vector<T>. In what order are they destroyed at scope exit?

{
    std::vector<T> v;
    v.reserve(3);
    v.emplace_back(1);
    v.emplace_back(2);
}
Question 1 of 4