blob: a18c4e69adc044d8a380018f802e6fb8e338b542 [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 multimap
13
14// multimap(initializer_list<value_type> il, const key_compare& comp, const allocator_type& a);
15
16#include <map>
17#include <cassert>
18#include "../../../test_compare.h"
19#include "../../../test_allocator.h"
20
21int main()
22{
Howard Hinnant73d21a42010-09-04 23:28:19 +000023#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000024 typedef test_compare<std::less<int> > Cmp;
25 typedef test_allocator<std::pair<const int, double> > A;
26 typedef std::multimap<int, double, Cmp, A> C;
27 typedef C::value_type V;
28 C m(
29 {
30 {1, 1},
31 {1, 1.5},
32 {1, 2},
33 {2, 1},
34 {2, 1.5},
35 {2, 2},
36 {3, 1},
37 {3, 1.5},
38 {3, 2}
39 },
40 Cmp(4), A(5)
41 );
42 assert(m.size() == 9);
43 assert(distance(m.begin(), m.end()) == 9);
44 C::const_iterator i = m.cbegin();
45 assert(*i == V(1, 1));
46 assert(*++i == V(1, 1.5));
47 assert(*++i == V(1, 2));
48 assert(*++i == V(2, 1));
49 assert(*++i == V(2, 1.5));
50 assert(*++i == V(2, 2));
51 assert(*++i == V(3, 1));
52 assert(*++i == V(3, 1.5));
53 assert(*++i == V(3, 2));
54 assert(m.key_comp() == Cmp(4));
55 assert(m.get_allocator() == A(5));
Howard Hinnant73d21a42010-09-04 23:28:19 +000056#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000057}