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 // <list> 10 11 // class list 12 13 // size_type size() const noexcept; 14 15 #include <list> 16 #include <cassert> 17 18 #include "test_macros.h" 19 #include "min_allocator.h" 20 main(int,char **)21int main(int, char**) 22 { 23 { 24 typedef std::list<int> C; 25 C c; 26 ASSERT_NOEXCEPT(c.size()); 27 assert(c.size() == 0); 28 c.push_back(C::value_type(2)); 29 assert(c.size() == 1); 30 c.push_back(C::value_type(1)); 31 assert(c.size() == 2); 32 c.push_back(C::value_type(3)); 33 assert(c.size() == 3); 34 c.erase(c.begin()); 35 assert(c.size() == 2); 36 c.erase(c.begin()); 37 assert(c.size() == 1); 38 c.erase(c.begin()); 39 assert(c.size() == 0); 40 } 41 #if TEST_STD_VER >= 11 42 { 43 typedef std::list<int, min_allocator<int>> C; 44 C c; 45 ASSERT_NOEXCEPT(c.size()); 46 assert(c.size() == 0); 47 c.push_back(C::value_type(2)); 48 assert(c.size() == 1); 49 c.push_back(C::value_type(1)); 50 assert(c.size() == 2); 51 c.push_back(C::value_type(3)); 52 assert(c.size() == 3); 53 c.erase(c.begin()); 54 assert(c.size() == 2); 55 c.erase(c.begin()); 56 assert(c.size() == 1); 57 c.erase(c.begin()); 58 assert(c.size() == 0); 59 } 60 #endif 61 62 return 0; 63 } 64