| 1 |
//===----------------------------------------------------------------------===// |
| 2 |
// |
| 3 |
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 |
// See https://llvm.org/LICENSE.txt for license information. |
| 5 |
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 |
// |
| 7 |
//===----------------------------------------------------------------------===// |
| 8 |
|
| 9 |
// UNSUPPORTED: c++03 |
| 10 |
|
| 11 |
// <map> |
| 12 |
|
| 13 |
// class multimap |
| 14 |
|
| 15 |
// multimap(initializer_list<value_type> il, const key_compare& comp = key_compare()); |
| 16 |
|
| 17 |
#include <map> |
| 18 |
#include <cassert> |
| 19 |
|
| 20 |
#include "test_macros.h" |
| 21 |
#include "min_allocator.h" |
| 22 |
|
| 23 |
int main(int, char**) |
| 24 |
{ |
| 25 |
{ |
| 26 |
typedef std::multimap<int, double> 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 |
assert(m.size() == 9); |
| 41 |
assert(std::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 |
} |
| 53 |
{ |
| 54 |
typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; |
| 55 |
typedef C::value_type V; |
| 56 |
C m = |
| 57 |
{ |
| 58 |
{1, 1}, |
| 59 |
{1, 1.5}, |
| 60 |
{1, 2}, |
| 61 |
{2, 1}, |
| 62 |
{2, 1.5}, |
| 63 |
{2, 2}, |
| 64 |
{3, 1}, |
| 65 |
{3, 1.5}, |
| 66 |
{3, 2} |
| 67 |
}; |
| 68 |
assert(m.size() == 9); |
| 69 |
assert(std::distance(m.begin(), m.end()) == 9); |
| 70 |
C::const_iterator i = m.cbegin(); |
| 71 |
assert(*i == V(1, 1)); |
| 72 |
assert(*++i == V(1, 1.5)); |
| 73 |
assert(*++i == V(1, 2)); |
| 74 |
assert(*++i == V(2, 1)); |
| 75 |
assert(*++i == V(2, 1.5)); |
| 76 |
assert(*++i == V(2, 2)); |
| 77 |
assert(*++i == V(3, 1)); |
| 78 |
assert(*++i == V(3, 1.5)); |
| 79 |
assert(*++i == V(3, 2)); |
| 80 |
} |
| 81 |
|
| 82 |
return 0; |
| 83 |
} |