14684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 24684ddb6SLionel Sambuc // 34684ddb6SLionel Sambuc // The LLVM Compiler Infrastructure 44684ddb6SLionel Sambuc // 54684ddb6SLionel Sambuc // This file is dual licensed under the MIT and the University of Illinois Open 64684ddb6SLionel Sambuc // Source Licenses. See LICENSE.TXT for details. 74684ddb6SLionel Sambuc // 84684ddb6SLionel Sambuc //===----------------------------------------------------------------------===// 94684ddb6SLionel Sambuc 104684ddb6SLionel Sambuc // <set> 114684ddb6SLionel Sambuc 124684ddb6SLionel Sambuc // class multiset 134684ddb6SLionel Sambuc 144684ddb6SLionel Sambuc // template <class... Args> 154684ddb6SLionel Sambuc // iterator emplace(Args&&... args); 164684ddb6SLionel Sambuc 174684ddb6SLionel Sambuc #include <set> 184684ddb6SLionel Sambuc #include <cassert> 194684ddb6SLionel Sambuc 204684ddb6SLionel Sambuc #include "../../Emplaceable.h" 21*0a6a1f1dSLionel Sambuc #include "DefaultOnly.h" 22*0a6a1f1dSLionel Sambuc #include "min_allocator.h" 234684ddb6SLionel Sambuc main()244684ddb6SLionel Sambucint main() 254684ddb6SLionel Sambuc { 264684ddb6SLionel Sambuc #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES 274684ddb6SLionel Sambuc { 284684ddb6SLionel Sambuc typedef std::multiset<DefaultOnly> M; 294684ddb6SLionel Sambuc typedef M::iterator R; 304684ddb6SLionel Sambuc M m; 314684ddb6SLionel Sambuc assert(DefaultOnly::count == 0); 324684ddb6SLionel Sambuc R r = m.emplace(); 334684ddb6SLionel Sambuc assert(r == m.begin()); 344684ddb6SLionel Sambuc assert(m.size() == 1); 354684ddb6SLionel Sambuc assert(*m.begin() == DefaultOnly()); 364684ddb6SLionel Sambuc assert(DefaultOnly::count == 1); 374684ddb6SLionel Sambuc 384684ddb6SLionel Sambuc r = m.emplace(); 394684ddb6SLionel Sambuc assert(r == next(m.begin())); 404684ddb6SLionel Sambuc assert(m.size() == 2); 414684ddb6SLionel Sambuc assert(*m.begin() == DefaultOnly()); 424684ddb6SLionel Sambuc assert(DefaultOnly::count == 2); 434684ddb6SLionel Sambuc } 444684ddb6SLionel Sambuc assert(DefaultOnly::count == 0); 454684ddb6SLionel Sambuc { 464684ddb6SLionel Sambuc typedef std::multiset<Emplaceable> M; 474684ddb6SLionel Sambuc typedef M::iterator R; 484684ddb6SLionel Sambuc M m; 494684ddb6SLionel Sambuc R r = m.emplace(); 504684ddb6SLionel Sambuc assert(r == m.begin()); 514684ddb6SLionel Sambuc assert(m.size() == 1); 524684ddb6SLionel Sambuc assert(*m.begin() == Emplaceable()); 534684ddb6SLionel Sambuc r = m.emplace(2, 3.5); 544684ddb6SLionel Sambuc assert(r == next(m.begin())); 554684ddb6SLionel Sambuc assert(m.size() == 2); 564684ddb6SLionel Sambuc assert(*r == Emplaceable(2, 3.5)); 574684ddb6SLionel Sambuc r = m.emplace(2, 3.5); 584684ddb6SLionel Sambuc assert(r == next(m.begin(), 2)); 594684ddb6SLionel Sambuc assert(m.size() == 3); 604684ddb6SLionel Sambuc assert(*r == Emplaceable(2, 3.5)); 614684ddb6SLionel Sambuc } 624684ddb6SLionel Sambuc { 634684ddb6SLionel Sambuc typedef std::multiset<int> M; 644684ddb6SLionel Sambuc typedef M::iterator R; 654684ddb6SLionel Sambuc M m; 664684ddb6SLionel Sambuc R r = m.emplace(M::value_type(2)); 674684ddb6SLionel Sambuc assert(r == m.begin()); 684684ddb6SLionel Sambuc assert(m.size() == 1); 694684ddb6SLionel Sambuc assert(*r == 2); 704684ddb6SLionel Sambuc } 714684ddb6SLionel Sambuc #if __cplusplus >= 201103L 724684ddb6SLionel Sambuc { 734684ddb6SLionel Sambuc typedef std::multiset<int, std::less<int>, min_allocator<int>> M; 744684ddb6SLionel Sambuc typedef M::iterator R; 754684ddb6SLionel Sambuc M m; 764684ddb6SLionel Sambuc R r = m.emplace(M::value_type(2)); 774684ddb6SLionel Sambuc assert(r == m.begin()); 784684ddb6SLionel Sambuc assert(m.size() == 1); 794684ddb6SLionel Sambuc assert(*r == 2); 804684ddb6SLionel Sambuc } 814684ddb6SLionel Sambuc #endif 824684ddb6SLionel Sambuc #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES 834684ddb6SLionel Sambuc } 84