insert_range.pass.cpp revision ba1920fe4b98e61fe47b432689c98b999f5139e3
1//===----------------------------------------------------------------------===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10// <unordered_map>
11
12// template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>,
13//           class Alloc = allocator<pair<const Key, T>>>
14// class unordered_map
15
16// template <class InputIterator>
17//     void insert(InputIterator first, InputIterator last);
18
19#include <unordered_map>
20#include <string>
21#include <cassert>
22
23#include "../../../../iterators.h"
24
25int main()
26{
27    {
28        typedef std::unordered_map<int, std::string> C;
29        typedef std::pair<int, std::string> P;
30        P a[] =
31        {
32            P(1, "one"),
33            P(2, "two"),
34            P(3, "three"),
35            P(4, "four"),
36            P(1, "four"),
37            P(2, "four"),
38        };
39        C c;
40        c.insert(input_iterator<P*>(a), input_iterator<P*>(a + sizeof(a)/sizeof(a[0])));
41        assert(c.size() == 4);
42        assert(c.at(1) == "one");
43        assert(c.at(2) == "two");
44        assert(c.at(3) == "three");
45        assert(c.at(4) == "four");
46    }
47}
48