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