Language: C++

#include <iostream>

using namespace std;

template<typename T>
class Node {
private:
    T _key;
    shared_ptr<Node<T>> _next;
    weak_ptr<Node<T>> _prev;
public:
    Node(T k): _key(k), _next(nullptr), _prev() {}

    T key() const { return _key; }
    shared_ptr<Node<T>> next() const { return _next; }
    shared_ptr<Node<T>> prev() const { return shared_ptr<Node<T>>(_prev); }

    bool is_first() const { return _prev.expired(); }
    bool is_last() const { return _next.get() == nullptr; }

    void set_first() { _prev = weak_ptr<Node<T>>(); }
    void set_last() { _next = nullptr; }

    void set_next(shared_ptr<Node<T>> next) {
        _next = next;
    }

    void set_prev(shared_ptr<Node<T>> prev) {
        _prev = weak_ptr<Node<T>>(prev);
    }
};

template<typename T>
class DoublyLinkedList {
private:
    shared_ptr<Node<T>> _first;
    shared_ptr<Node<T>> _last;
public:
    DoublyLinkedList():_first(nullptr), _last(nullptr) {}

    void insertNode(T key) {
        auto n = make_shared<Node<T>>(key);

        if (is_empty()) {
            _first = n;
            _last = n;
        } else {
            _first->set_prev(n);
            n->set_next(_first);
            _first = n;
        }

    }

    void deleteNode(T key) {
        auto n = _first;
        while(n != nullptr) {
            if (n->key() == key) {
                if (n->is_first() && n->is_last()) {
                    clear();
                } else if (n->is_first()) {
                    deleteFirst();
                } else if (n->is_last()) {
                    deleteLast();
                } else {
                    auto next = n->next();
                    auto prev = n->prev();
                    prev->set_next(next);
                    next->set_prev(prev);
                }
            }
            n = n->next();
        }
    }

    void deleteFirst() {
        if (_first->is_last()) {
            clear();
        } else {
            auto next = _first->next();
            _first = next;
            next->set_first();
        }
    }

    void deleteLast() {
        if (_last->is_first()) {
            clear();
        } else {
            auto prev = _last->prev();
            _last = prev;
            prev->set_last();
        }
    }

    bool is_empty() const { return _first.get() == nullptr; }
    void clear() {
        _first = nullptr;
        _last = nullptr;
    }

    string to_string() {
        auto n = _first;
        string s;
        while (n != nullptr) {
            s += std::to_string(n->key());
            if (n != _last)
                s += " ";
            n = n-> next();
        }
        return s;
    }
};

int main() {
    int n;
    cin >> n;

    DoublyLinkedList<int> list;

    for (int i = 0; i < n; i++) {
        string op;
        cin >> op;

        if (op == "insert") {
            int in;
            cin >> in;
            list.insertNode(in);
        } else if (op == "delete") {
            int in;
            cin >> in;
            list.deleteNode(in);
        } else if (op == "deleteFirst") {
            list.deleteFirst();
        } else if (op == "deleteLast") {
            list.deleteLast();
        }
    }

    cout << list.to_string() << endl;
    return 0;
}

Compiler output:
a.cc:9:5: error: 'shared_ptr' does not name a type
    9 |     shared_ptr<Node<T>> _next;
      |     ^~~~~~~~~~
a.cc:10:5: error: 'weak_ptr' does not name a type
   10 |     weak_ptr<Node<T>> _prev;
      |     ^~~~~~~~
a.cc:15:5: error: 'shared_ptr' does not name a type
   15 |     shared_ptr<Node<T>> next() const { return _next; }
      |     ^~~~~~~~~~
a.cc:16:5: error: 'shared_ptr' does not name a type
   16 |     shared_ptr<Node<T>> prev() const { return shared_ptr<Node<T>>(_prev); }
      |     ^~~~~~~~~~
a.cc:24:19: error: 'shared_ptr' has not been declared
   24 |     void set_next(shared_ptr<Node<T>> next) {
      |                   ^~~~~~~~~~
a.cc:24:29: error: expected ',' or '...' before '<' token
   24 |     void set_next(shared_ptr<Node<T>> next) {
      |                             ^
a.cc:28:19: error: 'shared_ptr' has not been declared
   28 |     void set_prev(shared_ptr<Node<T>> prev) {
      |                   ^~~~~~~~~~
a.cc:28:29: error: expected ',' or '...' before '<' token
   28 |     void set_prev(shared_ptr<Node<T>> prev) {
      |                             ^
a.cc: In constructor 'Node<T>::Node(T)':
a.cc:12:25: error: class 'Node<T>' does not have any field named '_next'
   12 |     Node(T k): _key(k), _next(nullptr), _prev() {}
      |                         ^~~~~
a.cc:12:41: error: class 'Node<T>' does not have any field named '_prev'
   12 |     Node(T k): _key(k), _next(nullptr), _prev() {}
      |                                         ^~~~~
a.cc: In member function 'bool Node<T>::is_first() const':
a.cc:18:36: error: '_prev' was not declared in this scope
   18 |     bool is_first() const { return _prev.expired(); }
      |                                    ^~~~~
a.cc: In member function 'bool Node<T>::is_last() const':
a.cc:19:35: error: '_next' was not declared in this scope
   19 |     bool is_last() const { return _next.get() == nullptr; }
      |                                   ^~~~~
a.cc: In member function 'void Node<T>::set_first()':
a.cc:21:24: error: '_prev' was not declared in this scope
   21 |     void set_first() { _prev = weak_ptr<Node<T>>(); }
      |                        ^~~~~
a.cc:21:32: error: 'weak_ptr' was not declared in this scope
   21 |     void set_first() { _prev = weak_ptr<Node<T>>(); }
      |                                ^~~~~~~~
a.cc:2:1: note: 'std::weak_ptr' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
    1 | #include <iostream>
  +++ |+#include <memory>
    2 | 
a.cc:21:47: error: expected primary-expression before '>' token
   21 |     void set_first() { _prev = weak_ptr<Node<T>>(); }
      |                                               ^~
a.cc:21:50: error: expected primary-expression before ')' token
   21 |     void set_first() { _prev = weak_ptr<Node<T>>(); }
      |                                                  ^
a.cc: In member function 'void Node<T>::set_last()':
a.cc:22:23: error: '_next' was not declared in this scope
   22 |     void set_last() { _next = nullptr; }
      |                       ^~~~~
a.cc: In member function 'void Node<T>::set_next(int)':
a.cc:25:9: error: '_next' was not declared in this scope
   25 |         _next = next;
      |         ^~~~~
a.cc: In member function 'void Node<T>::set_prev(int)':
a.cc:29:9: error: '_prev' was not declared in this scope
   29 |         _prev = weak_ptr<Node<T>>(prev);
      |         ^~~~~
a.cc:29:17: error: 'weak_ptr' was not declared in this scope
   29 |         _prev = weak_ptr<Node<T>>(prev);
      |                 ^~~~~~~~
a.cc:29:17: note: 'std::weak_ptr' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:29:32: error: expected primary-expression before '>' token
   29 |         _prev = weak_ptr<Node<T>>(prev);
      |                                ^~
a.cc: At global scope:
a.cc:36:5: error: 'shared_ptr' does not name a type
   36 |     shared_ptr<Node<T>> _first;
      |     ^~~~~~~~~~
a.cc:37:5: error: 'shared_ptr' does not name a type
   37 |     shared_ptr<Node<T>> _last;
      |     ^~~~~~~~~~
a.cc: In constructor 'DoublyLinkedList<T>::DoublyLinkedList()':
a.cc:39:24: error: class 'DoublyLinkedList<T>' does not have any field named '_first'
   39 |     DoublyLinkedList():_first(nullptr), _last(nullptr) {}
      |                        ^~~~~~
a.cc:39:41: error: class 'DoublyLinkedList<T>' does not have any field named '_last'
   39 |     DoublyLinkedList():_first(nullptr), _last(nullptr) {}
      |                                         ^~~~~
a.cc: In member function 'void DoublyLinkedList<T>::insertNode(T)':
a.cc:42:18: error: 'make_shared' was not declared in this scope
   42 |         auto n = make_shared<Node<T>>(key);
      |                  ^~~~~~~~~~~
a.cc:42:18: note: 'std::make_shared' is defined in header '<memory>'; this is probably fixable by adding '#include <memory>'
a.cc:42:36: error: expected primary-expression before '>' token
   42 |         auto n = make_shared<Node<T>>(key);
      |                                    ^~
a.cc:45:13: error: '_first' was not declared in this scope
   45 |             _first = n;
      |             ^~~~~~
a.cc:46:13: error: '_last' was not declared in this scope
   46 |             _last = n;
      |             ^~~~~
a.cc:48:13: error: '_first' was not declared in this scope
   48 |             _first->set_prev(n);
      |             ^~~~~~
a.cc: In member function 'void DoublyLinkedList<T>::deleteNode(T)':
a.cc:56:18: error: '_first' was not declared in this scope
   56 |         auto n = _first;
      |                  ^~~~~~
a.cc: In member function 'void DoublyLinkedList<T>::deleteFirst()':
a.cc:77:13: error: '_first' was not declared in this scope
   77 |         if (_first->is_last()) {
      |             ^~~~~~
a.cc: In member function 'void DoublyLinkedList<T>::deleteLast()':
a.cc:87:13: error: '_last' was not declared in this scope
   87 |         if (_last->is_first()) {
      |             ^~~~~
a.cc: In member function 'bool DoublyLinkedList<T>::is_empty() const':
a.cc:96:36: error: '_first' was not declared in this scope
   96 |     bool is_empty() const { return _first.get() == nullptr; }
      |                                    ^~~~~~
a.cc: In member function 'void DoublyLinkedList<T>::clear()':
a.cc:98:9: error: '_first' was not declared in this scope
   98 |         _first = nullptr;
      |         ^~~~~~
a.cc:99:9: error: '_last' was not declared in this scope
   99 |         _last = nullptr;
      |         ^~~~~
a.cc: In member function 'std::string DoublyLinkedList<T>::to_string()':
a.cc:103:18: error: '_first' was not declared in this scope
  103 |         auto n = _first;
      |                  ^~~~~~
a.cc:107:22: error: '_last' was not declared in this scope
  107 |             if (n != _last)
      |                      ^~~~~