blob: 6d7f546ea41065a7af4263376adfd6580eaba5d8 [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//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <map>
11
12// class multimap
13
14// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare());
15
16#include <map>
17#include <cassert>
18#include "../../../test_compare.h"
19
20int main()
21{
Howard Hinnante3e32912011-08-12 21:56:02 +000022#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000023 typedef test_compare<std::less<int> > Cmp;
24 typedef std::multimap<int, double, Cmp> C;
25 typedef C::value_type V;
26 C m(
27 {
28 {1, 1},
29 {1, 1.5},
30 {1, 2},
31 {2, 1},
32 {2, 1.5},
33 {2, 2},
34 {3, 1},
35 {3, 1.5},
36 {3, 2}
37 },
38 Cmp(4)
39 );
40 assert(m.size() == 9);
41 assert(distance(m.begin(), m.end()) == 9);
42 C::const_iterator i = m.cbegin();
43 assert(*i == V(1, 1));
44 assert(*++i == V(1, 1.5));
45 assert(*++i == V(1, 2));
46 assert(*++i == V(2, 1));
47 assert(*++i == V(2, 1.5));
48 assert(*++i == V(2, 2));
49 assert(*++i == V(3, 1));
50 assert(*++i == V(3, 1.5));
51 assert(*++i == V(3, 2));
52 assert(m.key_comp() == Cmp(4));
Howard Hinnante3e32912011-08-12 21:56:02 +000053#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000054}