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(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 | R r = c.insert(P(3.5)); |
| 31 | assert(c.size() == 1); |
| 32 | assert(*r == 3.5); |
| 33 | |
| 34 | r = c.insert(P(3.5)); |
| 35 | assert(c.size() == 2); |
| 36 | assert(*r == 3.5); |
| 37 | |
| 38 | r = c.insert(P(4.5)); |
| 39 | assert(c.size() == 3); |
| 40 | assert(*r == 4.5); |
| 41 | |
| 42 | r = c.insert(P(5.5)); |
| 43 | assert(c.size() == 4); |
| 44 | assert(*r == 5.5); |
| 45 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 46 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 47 | { |
| 48 | typedef std::unordered_multiset<MoveOnly> C; |
| 49 | typedef C::iterator R; |
| 50 | typedef MoveOnly P; |
| 51 | C c; |
| 52 | R r = c.insert(P(3)); |
| 53 | assert(c.size() == 1); |
| 54 | assert(*r == 3); |
| 55 | |
| 56 | r = c.insert(P(3)); |
| 57 | assert(c.size() == 2); |
| 58 | assert(*r == 3); |
| 59 | |
| 60 | r = c.insert(P(4)); |
| 61 | assert(c.size() == 3); |
| 62 | assert(*r == 4); |
| 63 | |
| 64 | r = c.insert(P(5)); |
| 65 | assert(c.size() == 4); |
| 66 | assert(*r == 5); |
| 67 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 68 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 69 | } |