1 //===----------------------------------------------------------------------===// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // <deque> 10 11 // void clear() noexcept; 12 13 #include <deque> 14 #include <cassert> 15 16 #include "test_macros.h" 17 #include "../../../NotConstructible.h" 18 #include "min_allocator.h" 19 20 int main(int, char**) 21 { 22 { 23 typedef NotConstructible T; 24 typedef std::deque<T> C; 25 C c; 26 ASSERT_NOEXCEPT(c.clear()); 27 c.clear(); 28 assert(std::distance(c.begin(), c.end()) == 0); 29 } 30 { 31 typedef int T; 32 typedef std::deque<T> C; 33 const T t[] = {0, 1, 2, 3, 4}; 34 C c(std::begin(t), std::end(t)); 35 36 ASSERT_NOEXCEPT(c.clear()); 37 c.clear(); 38 assert(std::distance(c.begin(), c.end()) == 0); 39 40 c.clear(); 41 assert(std::distance(c.begin(), c.end()) == 0); 42 } 43 #if TEST_STD_VER >= 11 44 { 45 typedef NotConstructible T; 46 typedef std::deque<T, min_allocator<T>> C; 47 C c; 48 ASSERT_NOEXCEPT(c.clear()); 49 c.clear(); 50 assert(std::distance(c.begin(), c.end()) == 0); 51 } 52 { 53 typedef int T; 54 typedef std::deque<T, min_allocator<T>> C; 55 const T t[] = {0, 1, 2, 3, 4}; 56 C c(std::begin(t), std::end(t)); 57 58 ASSERT_NOEXCEPT(c.clear()); 59 c.clear(); 60 assert(std::distance(c.begin(), c.end()) == 0); 61 62 c.clear(); 63 assert(std::distance(c.begin(), c.end()) == 0); 64 } 65 #endif 66 67 return 0; 68 } 69