llvm-project
70 строк · 1.7 Кб
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// <map>
10
11// class map
12
13// template <class InputIterator>
14// map(InputIterator first, InputIterator last);
15
16#include <map>17#include <cassert>18
19#include "test_macros.h"20#include "min_allocator.h"21
22int main(int, char**)23{
24{25typedef std::pair<const int, double> V;26V ar[] =27{28V(1, 1),29V(1, 1.5),30V(1, 2),31V(2, 1),32V(2, 1.5),33V(2, 2),34V(3, 1),35V(3, 1.5),36V(3, 2),37};38std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));39assert(m.size() == 3);40assert(std::distance(m.begin(), m.end()) == 3);41assert(*m.begin() == V(1, 1));42assert(*std::next(m.begin()) == V(2, 1));43assert(*std::next(m.begin(), 2) == V(3, 1));44}45#if TEST_STD_VER >= 1146{47typedef std::pair<const int, double> V;48V ar[] =49{50V(1, 1),51V(1, 1.5),52V(1, 2),53V(2, 1),54V(2, 1.5),55V(2, 2),56V(3, 1),57V(3, 1.5),58V(3, 2),59};60std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m(ar, ar+sizeof(ar)/sizeof(ar[0]));61assert(m.size() == 3);62assert(std::distance(m.begin(), m.end()) == 3);63assert(*m.begin() == V(1, 1));64assert(*std::next(m.begin()) == V(2, 1));65assert(*std::next(m.begin(), 2) == V(3, 1));66}67#endif68
69return 0;70}
71