#include <utility>
#include <iostream>
#include <memory>

struct other
{
    other(std::string const& foo) : m_foo(foo) {}
    ~other() { std::cout << "~other(" << m_foo << ")\n"; }
    std::string m_foo;
};

int main()
{
    std::shared_ptr<int> spi;

    {
        std::shared_ptr<std::pair<int, other> > spp = std::make_shared<std::pair<int, other> >(42, other("arg"));
        spp->second.m_foo = "shared_ptr copy";
        spi = std::shared_ptr<int>(spp, &(spp->first));
    }

    std::cout << *spi << "\n";
    std::cout << "resetting spi...\n";
    spi.reset();
    std::cout << "done.\n";
}
