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 value_type& v);
14 
15 #include <set>
16 #include <cassert>
17 
18 #include "min_allocator.h"
19 
20 template<class Container>
21 void do_insert_cv_test()
22 {
23     typedef Container M;
24     typedef typename M::iterator R;
25     typedef typename M::value_type VT;
26     M m;
27     const VT v1(2);
28     R r = m.insert(v1);
29     assert(r == m.begin());
30     assert(m.size() == 1);
31     assert(*r == 2);
32 
33     const VT v2(1);
34     r = m.insert(v2);
35     assert(r == m.begin());
36     assert(m.size() == 2);
37     assert(*r == 1);
38 
39     const VT v3(3);
40     r = m.insert(v3);
41     assert(r == prev(m.end()));
42     assert(m.size() == 3);
43     assert(*r == 3);
44 
45     r = m.insert(v3);
46     assert(r == prev(m.end()));
47     assert(m.size() == 4);
48     assert(*r == 3);
49 }
50 
51 int main(int, char**)
52 {
53     do_insert_cv_test<std::multiset<int> >();
54 #if TEST_STD_VER >= 11
55     {
56         typedef std::multiset<int, std::less<int>, min_allocator<int>> M;
57         do_insert_cv_test<M>();
58     }
59 #endif
60 
61   return 0;
62 }
63