Sobes.tech
Junior — Middle+

Check if memory is freed when calling resize on std::vector

livecode

Task condition

It is necessary to determine whether the previously allocated memory will be freed after executing the resize method.

void vector_method()
{
    std::vector<int> v1;
    // ========
    v1.push_back(1);
    v1.push_back(2);

    std::vector<int> v2;
    v2.swap(v1);

    v2.resize(0);
}