1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <deque> 11 12// void pop_front() 13 14// Erasing items from the beginning or the end of a deque shall not invalidate iterators 15// to items that were not erased. 16 17#include <deque> 18#include <cassert> 19 20template <typename C> 21void test(C c) 22{ 23 typename C::iterator it1 = c.begin() + 1; 24 typename C::iterator it2 = c.end() - 1; 25 26 c.pop_front(); 27 28 typename C::iterator it3 = c.begin(); 29 typename C::iterator it4 = c.end() - 1; 30 assert( it1 == it3); 31 assert( *it1 == *it3); 32 assert(&*it1 == &*it3); 33 assert( it2 == it4); 34 assert( *it2 == *it4); 35 assert(&*it2 == &*it4); 36} 37 38int main() 39{ 40 std::deque<int> queue; 41 for (int i = 0; i < 20; ++i) 42 queue.push_back(i); 43 44 while (queue.size() > 1) 45 { 46 test(queue); 47 queue.pop_back(); 48 } 49} 50