#include <iostream>
#include <vector>
#include <memory>
#include <algorithm>
using namespace std;

class Story
{
    int n;
public:
    Story(int n): n(n) { cout << "story #" << n << " created" << endl; }
    ~Story() { cout << "story #" << n << " destroyed" << endl; }
};

int main()
{
    vector<shared_ptr<Story>> list1, list2, list3, list4;

    auto story1 = make_shared<Story>(1);
    auto story2 = make_shared<Story>(2);

    list1.push_back(story1); list1.push_back(story2);
    list2.push_back(story2); list1.push_back(story1);
    list3.push_back(story1);
    list4.push_back(story2);

    list1.erase(remove(begin(list1), end(list1), story1), end(list1));
    list2.erase(remove(begin(list2), end(list2), story1), end(list2));
    list3.erase(remove(begin(list3), end(list3), story1), end(list3));
    list4.erase(remove(begin(list4), end(list4), story1), end(list4));
    
    story1 = nullptr; // story1 -- тоже указатель на объект
    cout << "story1 should be destroyed here" << endl;
}