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