clear.pass.cpp (1658B)
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 clear() noexcept; 13 14 #include <deque> 15 #include <cassert> 16 17 #include "test_macros.h" 18 #include "../../../NotConstructible.h" 19 #include "min_allocator.h" 20 21 int main() 22 { 23 { 24 typedef NotConstructible T; 25 typedef std::deque<T> C; 26 C c; 27 ASSERT_NOEXCEPT(c.clear()); 28 c.clear(); 29 assert(distance(c.begin(), c.end()) == 0); 30 } 31 { 32 typedef int T; 33 typedef std::deque<T> C; 34 const T t[] = {0, 1, 2, 3, 4}; 35 C c(std::begin(t), std::end(t)); 36 37 ASSERT_NOEXCEPT(c.clear()); 38 c.clear(); 39 assert(distance(c.begin(), c.end()) == 0); 40 41 c.clear(); 42 assert(distance(c.begin(), c.end()) == 0); 43 } 44 #if TEST_STD_VER >= 11 45 { 46 typedef NotConstructible T; 47 typedef std::deque<T, min_allocator<T>> C; 48 C c; 49 ASSERT_NOEXCEPT(c.clear()); 50 c.clear(); 51 assert(distance(c.begin(), c.end()) == 0); 52 } 53 { 54 typedef int T; 55 typedef std::deque<T, min_allocator<T>> C; 56 const T t[] = {0, 1, 2, 3, 4}; 57 C c(std::begin(t), std::end(t)); 58 59 ASSERT_NOEXCEPT(c.clear()); 60 c.clear(); 61 assert(distance(c.begin(), c.end()) == 0); 62 63 c.clear(); 64 assert(distance(c.begin(), c.end()) == 0); 65 } 66 #endif 67 }