Post

C++ std -- deque

pop_front

Below code has a bug

1
auto& element = que.pop_front()

According to the standard, reference to the popped element will be invalidated, so we should create a copy instead of reference. The implementation is here. You can see that is calls allocator_traits::destroy to free the object.

This post is licensed under CC BY 4.0 by the author.