This is the section that messes up. It's meant to de-reference _head->prev to a nullptr but if there is no prev it crashes so I'm attempting to handle that crash. When it gets to
if( _head )
(!_head->prev)
It messes up as there is no previous. I cannot figure out how to write an if statement to handle this moment so that it wont break. If there is no prev I just want it to --_size delete tmpnode and return result.
template <class list>
list linked_list<list>::pop_front()
{
assert( !empty() );
node_ptr_t tmpNode(_head);
list result = _head->data;
if(_head->next)
_head = _head->next;
else
_head = _tail;
if ( _head )
if(!_head->prev)
{
--_size;
delete tmpNode;
return result;
}else{
_head->prev = nullptr;
}else {
_tail = nullptr;
}
//_head ? _head->prev=nullptr : _tail=nullptr;
--_size;
delete tmpNode;
return result;
}