#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <utility>
#include <memory>
#include <cassert>
using namespace std;

unique_ptr<string[]> create_array(size_t n, string s) {
    auto up = make_unique<string[]>(n);
    for (size_t i = 0; i < n; ++i) {
        up[i] = s;
    }
    return up;
}

int main() {
    size_t n = 1000;
    unique_ptr<string[]> up1 = create_array(n, "hello");
  
    // unique_ptr holds just a pointer
    static_assert(sizeof(up1) == 8);

    for (size_t i = 0; i < n; ++i) { assert(up1[i] == "hello"s); }

    unique_ptr<string[]> up2;
    assert(!up2);

    // This doesn't compile -- unique_ptr cannot be copied
    // up2 = up1;

    // But it can be moved
    up2 = std::move(up1);
    assert(!up1 && up2);

    // It can also be moved to a shared_ptr
    shared_ptr<string[]> sp { std::move(up2) };
    assert(!up2 && sp.use_count() == 1);

    for (size_t i = 0; i < n; ++i) { assert(sp[i] == "hello"s); }
}
