Values & References11 / 16
Up next

Copy versus move

#include <print>
#include <vector>
#include <utility>

int main() {
    std::vector<int> a{1, 2, 3};
    // a copy leaves the source intact
    std::vector<int> copy = a;
    // a move empties the source into the target
    std::vector<int> moved = std::move(a);
    std::println("{} {} {}", copy.size(), moved.size(), a.size());
}
What you're solving

one duplicates, the other transfers