insert_rv.pass.cpp revision 73d21a4f0774d3fadab98e690619a359cfb160a3
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
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// iterator insert(value_type&& v);
15
16#include <set>
17#include <cassert>
18
19#include "../../MoveOnly.h"
20
21int main()
22{
23#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
24    {
25        typedef std::multiset<MoveOnly> M;
26        typedef M::iterator R;
27        M m;
28        R r = m.insert(M::value_type(2));
29        assert(r == m.begin());
30        assert(m.size() == 1);
31        assert(*r == 2);
32
33        r = m.insert(M::value_type(1));
34        assert(r == m.begin());
35        assert(m.size() == 2);
36        assert(*r == 1);
37
38        r = m.insert(M::value_type(3));
39        assert(r == prev(m.end()));
40        assert(m.size() == 3);
41        assert(*r == 3);
42
43        r = m.insert(M::value_type(3));
44        assert(r == prev(m.end()));
45        assert(m.size() == 4);
46        assert(*r == 3);
47    }
48#endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
49}
50