4 ms·
pop_back is about to invoke a destructor. Remember unlike what the name would suggest, it's not actually returning the element it removed - it's equivalent to e
by kllrnohj 4y ago
pop_back is about to invoke a destructor. Remember unlike what the name would suggest, it's not actually returning the element it removed - it's equivalent to erase(end() - 1). So adding a bounds check is going to be inconsequential in nearly any usage. And if you're doing a lot of pop_backs all at once, then if you cared about Real Speed you'd obviously be using the range erase() to do it all in one go.