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 // multiset(initializer_list<value_type> il, const key_compare& comp = key_compare()); 15 16 #include <set> 17 #include <cassert> 18 19 #include "min_allocator.h" 20 21 int main() 22 { 23 #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 24 { 25 typedef std::multiset<int> C; 26 typedef C::value_type V; 27 C m = {1, 2, 3, 4, 5, 6}; 28 assert(m.size() == 6); 29 assert(distance(m.begin(), m.end()) == 6); 30 C::const_iterator i = m.cbegin(); 31 assert(*i == V(1)); 32 assert(*++i == V(2)); 33 assert(*++i == V(3)); 34 assert(*++i == V(4)); 35 assert(*++i == V(5)); 36 assert(*++i == V(6)); 37 } 38 #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS 39 #if __cplusplus >= 201103L 40 { 41 typedef std::multiset<int, std::less<int>, min_allocator<int>> C; 42 typedef C::value_type V; 43 C m = {1, 2, 3, 4, 5, 6}; 44 assert(m.size() == 6); 45 assert(distance(m.begin(), m.end()) == 6); 46 C::const_iterator i = m.cbegin(); 47 assert(*i == V(1)); 48 assert(*++i == V(2)); 49 assert(*++i == V(3)); 50 assert(*++i == V(4)); 51 assert(*++i == V(5)); 52 assert(*++i == V(6)); 53 } 54 #if _LIBCPP_STD_VER > 11 55 { 56 typedef std::multiset<int, std::less<int>, min_allocator<int>> C; 57 typedef C::value_type V; 58 min_allocator<int> a; 59 C m ({1, 2, 3, 4, 5, 6}, a); 60 assert(m.size() == 6); 61 assert(distance(m.begin(), m.end()) == 6); 62 C::const_iterator i = m.cbegin(); 63 assert(*i == V(1)); 64 assert(*++i == V(2)); 65 assert(*++i == V(3)); 66 assert(*++i == V(4)); 67 assert(*++i == V(5)); 68 assert(*++i == V(6)); 69 assert(m.get_allocator() == a); 70 } 71 #endif 72 #endif 73 } 74