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 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame^] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <map> |
| 11 | |
| 12 | // class map |
| 13 | |
| 14 | // template <class P> |
| 15 | // pair<iterator, bool> insert(P&& p); |
| 16 | |
| 17 | #include <map> |
| 18 | #include <cassert> |
| 19 | |
| 20 | #include "../../../MoveOnly.h" |
| 21 | |
| 22 | int main() |
| 23 | { |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 24 | #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 25 | { |
| 26 | typedef std::map<int, MoveOnly> M; |
| 27 | typedef std::pair<M::iterator, bool> R; |
| 28 | M m; |
| 29 | R r = m.insert(M::value_type(2, 2)); |
| 30 | assert(r.second); |
| 31 | assert(r.first == m.begin()); |
| 32 | assert(m.size() == 1); |
| 33 | assert(r.first->first == 2); |
| 34 | assert(r.first->second == 2); |
| 35 | |
| 36 | r = m.insert(M::value_type(1, 1)); |
| 37 | assert(r.second); |
| 38 | assert(r.first == m.begin()); |
| 39 | assert(m.size() == 2); |
| 40 | assert(r.first->first == 1); |
| 41 | assert(r.first->second == 1); |
| 42 | |
| 43 | r = m.insert(M::value_type(3, 3)); |
| 44 | assert(r.second); |
| 45 | assert(r.first == prev(m.end())); |
| 46 | assert(m.size() == 3); |
| 47 | assert(r.first->first == 3); |
| 48 | assert(r.first->second == 3); |
| 49 | |
| 50 | r = m.insert(M::value_type(3, 3)); |
| 51 | assert(!r.second); |
| 52 | assert(r.first == prev(m.end())); |
| 53 | assert(m.size() == 3); |
| 54 | assert(r.first->first == 3); |
| 55 | assert(r.first->second == 3); |
| 56 | } |
Howard Hinnant | 73d21a4 | 2010-09-04 23:28:19 +0000 | [diff] [blame] | 57 | #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 58 | } |