Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <unordered_set> |
| 11 | |
| 12 | // template <class Value, class Hash = hash<Value>, class Pred = equal_to<Value>, |
| 13 | // class Alloc = allocator<Value>> |
| 14 | // class unordered_multiset |
| 15 | |
| 16 | // iterator insert(const_iterator p, value_type&& x); |
| 17 | |
| 18 | #include <unordered_set> |
| 19 | #include <cassert> |
| 20 | |
| 21 | #include "../../MoveOnly.h" |
| 22 | |
| 23 | int main() |
| 24 | { |
| 25 | { |
| 26 | typedef std::unordered_multiset<double> C; |
| 27 | typedef C::iterator R; |
| 28 | typedef double P; |
| 29 | C c; |
| 30 | C::const_iterator e = c.end(); |
| 31 | R r = c.insert(e, P(3.5)); |
| 32 | assert(c.size() == 1); |
| 33 | assert(*r == 3.5); |
| 34 | |
| 35 | r = c.insert(r, P(3.5)); |
| 36 | assert(c.size() == 2); |
| 37 | assert(*r == 3.5); |
| 38 | |
| 39 | r = c.insert(e, P(4.5)); |
| 40 | assert(c.size() == 3); |
| 41 | assert(*r == 4.5); |
| 42 | |
| 43 | r = c.insert(e, P(5.5)); |
| 44 | assert(c.size() == 4); |
| 45 | assert(*r == 5.5); |
| 46 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 47 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 48 | { |
| 49 | typedef std::unordered_multiset<MoveOnly> C; |
| 50 | typedef C::iterator R; |
| 51 | typedef MoveOnly P; |
| 52 | C c; |
| 53 | C::const_iterator e = c.end(); |
| 54 | R r = c.insert(e, P(3)); |
| 55 | assert(c.size() == 1); |
| 56 | assert(*r == 3); |
| 57 | |
| 58 | r = c.insert(r, P(3)); |
| 59 | assert(c.size() == 2); |
| 60 | assert(*r == 3); |
| 61 | |
| 62 | r = c.insert(e, P(4)); |
| 63 | assert(c.size() == 3); |
| 64 | assert(*r == 4); |
| 65 | |
| 66 | r = c.insert(e, P(5)); |
| 67 | assert(c.size() == 4); |
| 68 | assert(*r == 5); |
| 69 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 70 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 71 | } |