| 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 |
// <unordered_set> |
| 10 |
|
| 11 |
// template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, |
| 12 |
// class Alloc = allocator<Value>> |
| 13 |
// class unordered_multiset |
| 14 |
|
| 15 |
// iterator insert(const_iterator p, const value_type& x); |
| 16 |
|
| 17 |
#include <unordered_set> |
| 18 |
#include <cassert> |
| 19 |
|
| 20 |
#include "test_macros.h" |
| 21 |
#include "min_allocator.h" |
| 22 |
|
| 23 |
template<class Container> |
| 24 |
void do_insert_hint_const_lvalue_test() |
| 25 |
{ |
| 26 |
typedef Container C; |
| 27 |
typedef typename C::iterator R; |
| 28 |
typedef typename C::value_type VT; |
| 29 |
C c; |
| 30 |
typename C::const_iterator e = c.end(); |
| 31 |
const VT v1(3.5); |
| 32 |
R r = c.insert(e, v1); |
| 33 |
assert(c.size() == 1); |
| 34 |
assert(*r == 3.5); |
| 35 |
|
| 36 |
r = c.insert(r, v1); |
| 37 |
assert(c.size() == 2); |
| 38 |
assert(*r == 3.5); |
| 39 |
|
| 40 |
const VT v2(4.5); |
| 41 |
r = c.insert(c.end(), v2); |
| 42 |
assert(c.size() == 3); |
| 43 |
assert(*r == 4.5); |
| 44 |
|
| 45 |
const VT v3(5.5); |
| 46 |
r = c.insert(c.end(), v3); |
| 47 |
assert(c.size() == 4); |
| 48 |
assert(*r == 5.5); |
| 49 |
} |
| 50 |
|
| 51 |
int main(int, char**) |
| 52 |
{ |
| 53 |
do_insert_hint_const_lvalue_test<std::unordered_multiset<double> >(); |
| 54 |
#if TEST_STD_VER >= 11 |
| 55 |
{ |
| 56 |
typedef std::unordered_multiset<double, std::hash<double>, |
| 57 |
std::equal_to<double>, min_allocator<double>> C; |
| 58 |
do_insert_hint_const_lvalue_test<C>(); |
| 59 |
} |
| 60 |
#endif |
| 61 |
|
| 62 |
return 0; |
| 63 |
} |