| 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 | // <set> |
| 10 | |
| 11 | // class multiset |
| 12 | |
| 13 | // iterator insert(const_iterator position, const value_type& v); |
| 14 | |
| 15 | #include <set> |
| 16 | #include <cassert> |
| 17 | |
| 18 | #include "test_macros.h" |
| 19 | #include "min_allocator.h" |
| 20 | |
| 21 | int main(int, char**) { |
| 22 | { |
| 23 | typedef std::multiset<int> M; |
| 24 | typedef M::iterator R; |
| 25 | M m; |
| 26 | R r = m.insert(position: m.cend(), x: M::value_type(2)); |
| 27 | assert(r == m.begin()); |
| 28 | assert(m.size() == 1); |
| 29 | assert(*r == 2); |
| 30 | |
| 31 | r = m.insert(position: m.cend(), x: M::value_type(1)); |
| 32 | assert(r == m.begin()); |
| 33 | assert(m.size() == 2); |
| 34 | assert(*r == 1); |
| 35 | |
| 36 | r = m.insert(position: m.cend(), x: M::value_type(3)); |
| 37 | assert(r == std::prev(m.end())); |
| 38 | assert(m.size() == 3); |
| 39 | assert(*r == 3); |
| 40 | |
| 41 | r = m.insert(position: m.cend(), x: M::value_type(3)); |
| 42 | assert(r == std::prev(m.end())); |
| 43 | assert(m.size() == 4); |
| 44 | assert(*r == 3); |
| 45 | } |
| 46 | #if TEST_STD_VER >= 11 |
| 47 | { |
| 48 | typedef std::multiset<int, std::less<int>, min_allocator<int>> M; |
| 49 | typedef M::iterator R; |
| 50 | M m; |
| 51 | R r = m.insert(m.cend(), M::value_type(2)); |
| 52 | assert(r == m.begin()); |
| 53 | assert(m.size() == 1); |
| 54 | assert(*r == 2); |
| 55 | |
| 56 | r = m.insert(m.cend(), M::value_type(1)); |
| 57 | assert(r == m.begin()); |
| 58 | assert(m.size() == 2); |
| 59 | assert(*r == 1); |
| 60 | |
| 61 | r = m.insert(m.cend(), M::value_type(3)); |
| 62 | assert(r == std::prev(m.end())); |
| 63 | assert(m.size() == 3); |
| 64 | assert(*r == 3); |
| 65 | |
| 66 | r = m.insert(m.cend(), M::value_type(3)); |
| 67 | assert(r == std::prev(m.end())); |
| 68 | assert(m.size() == 4); |
| 69 | assert(*r == 3); |
| 70 | } |
| 71 | #endif |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |