C ++ 98, section 23.2.1 (template class class)
"Deque ... supports inserting and deleting the time constant at the beginning or at the end, pasting and erasing in the middle of dle takes linear time. That is, deque is especially optimized for pushing and popping elements to the beginning and end. As with vectors , storage management is processed automatically.
So yes: O (1) insert at both ends.
source share