emplace.pass.cpp revision f5256e16dfc425c1d466f6308d4026d529ce9e0b
169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//===----------------------------------------------------------------------===//
269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//
369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//                     The LLVM Compiler Infrastructure
469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//
569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// This file is distributed under the University of Illinois Open Source
669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// License. See LICENSE.TXT for details.
769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//
869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//===----------------------------------------------------------------------===//
969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
1069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// <unordered_map>
1169e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
1269e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
1369e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//           class Alloc = allocator<pair<const Key, T>>>
1469e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// class unordered_map
1569e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
1669e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal// template <class... Args>
1769e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal//     pair<iterator, bool> emplace(Args&&... args);
1869e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal
1969e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#include <unordered_map>
2069e17611504376e4d4603925f8528dfc890fd2c6Luis Sigal#include <cassert>
21
22#include "../../../Emplaceable.h"
23
24int main()
25{
26#ifdef _LIBCPP_MOVE
27    {
28        typedef std::unordered_map<int, Emplaceable> C;
29        typedef std::pair<C::iterator, bool> R;
30        C c;
31        R r = c.emplace(3);
32        assert(r.second);
33        assert(c.size() == 1);
34        assert(r.first->first == 3);
35        assert(r.first->second == Emplaceable());
36
37        r = c.emplace(std::pair<const int, Emplaceable>(4, Emplaceable(5, 6)));
38        assert(r.second);
39        assert(c.size() == 2);
40        assert(r.first->first == 4);
41        assert(r.first->second == Emplaceable(5, 6));
42
43        r = c.emplace(5, 6, 7);
44        assert(r.second);
45        assert(c.size() == 3);
46        assert(r.first->first == 5);
47        assert(r.first->second == Emplaceable(6, 7));
48    }
49#endif
50}
51