Skip to main content
2 of 2
added 356 characters in body
AlexT
  • 263
  • 1
  • 6

There is small possibility to have memory leak here:

    _head = new Node;
    _tail = new Node;

consider if after successfull allocaiton of first Node you get std::bad_alloc on second Node

Class invariant is not preserved here:

    _size++;
    return iterator( p->_prev = p->_prev->_next = new Node( x, p->_prev, p ) );

Again there is small posibility of std::bad_alloc when you create new Node but you have already increased _size

By the way - I remember leading underscores are discouraged from usage in application code

AlexT
  • 263
  • 1
  • 6