Sobes.tech
Junior — Senior

Code behavior analysis using std::vector

livecode

Task condition

Predict how the given code fragment will execute, whether memory allocation and copying operations will occur.

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

    std::vector<int> b;
    b.swap(a);
}