blob: b19adb23c39e8e4eea5b33712871303a540ea77b [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
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
22int main()
23{
Howard Hinnant73d21a42010-09-04 23:28:19 +000024#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000025 {
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 Hinnant73d21a42010-09-04 23:28:19 +000057#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000058}