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 | // <set> |
| 11 | |
| 12 | // class multiset |
| 13 | |
| 14 | // template <class... Args> |
| 15 | // iterator emplace_hint(const_iterator position, Args&&... args); |
| 16 | |
| 17 | #include <set> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "../../Emplaceable.h" |
| 21 | #include "../../DefaultOnly.h" |
| 22 | |
| 23 | int main() |
| 24 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame^] | 25 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 26 | { |
| 27 | typedef std::multiset<DefaultOnly> M; |
| 28 | typedef M::iterator R; |
| 29 | M m; |
| 30 | assert(DefaultOnly::count == 0); |
| 31 | R r = m.emplace_hint(m.cend()); |
| 32 | assert(r == m.begin()); |
| 33 | assert(m.size() == 1); |
| 34 | assert(*m.begin() == DefaultOnly()); |
| 35 | assert(DefaultOnly::count == 1); |
| 36 | |
| 37 | r = m.emplace_hint(m.cbegin()); |
| 38 | assert(r == m.begin()); |
| 39 | assert(m.size() == 2); |
| 40 | assert(*m.begin() == DefaultOnly()); |
| 41 | assert(DefaultOnly::count == 2); |
| 42 | } |
| 43 | assert(DefaultOnly::count == 0); |
| 44 | { |
| 45 | typedef std::multiset<Emplaceable> M; |
| 46 | typedef M::iterator R; |
| 47 | M m; |
| 48 | R r = m.emplace_hint(m.cend()); |
| 49 | assert(r == m.begin()); |
| 50 | assert(m.size() == 1); |
| 51 | assert(*m.begin() == Emplaceable()); |
| 52 | r = m.emplace_hint(m.cend(), 2, 3.5); |
| 53 | assert(r == next(m.begin())); |
| 54 | assert(m.size() == 2); |
| 55 | assert(*r == Emplaceable(2, 3.5)); |
| 56 | r = m.emplace_hint(m.cbegin(), 2, 3.5); |
| 57 | assert(r == next(m.begin())); |
| 58 | assert(m.size() == 3); |
| 59 | assert(*r == Emplaceable(2, 3.5)); |
| 60 | } |
| 61 | { |
| 62 | typedef std::multiset<int> M; |
| 63 | typedef M::iterator R; |
| 64 | M m; |
| 65 | R r = m.emplace_hint(m.cend(), M::value_type(2)); |
| 66 | assert(r == m.begin()); |
| 67 | assert(m.size() == 1); |
| 68 | assert(*r == 2); |
| 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 | } |