// Copia profunda y copy and swap, con las reservas contadas.
#include <iostream>

#include "alloc_count.h"
#include "int_buffer.h"

void report(const char* step, const IntBuffer& a, const IntBuffer& b) {
    std::cout << step << ": a.at(0)=" << a.at(0) << " b.at(0)=" << b.at(0)
              << " | new[]=" << array_news() << " delete[]=" << array_deletes() << "\n";
}

int main() {
    IntBuffer a(3);
    a.at(0) = 10;
    IntBuffer b(a);
    report("copia", a, b);

    b.at(0) = 99;
    report("cambio b", a, b);

    IntBuffer c(5);
    c.at(0) = 7;
    b = c;
    report("b = c", a, b);
    std::cout << "b.size()=" << b.size() << "\n";

    IntBuffer& same = b;
    b = same;
    report("b = b", a, b);
    std::cout << "b.size()=" << b.size() << "\n";
    return 0;
}
