insert_iter_iter.pass.cpp revision b64f8b07c104c6cc986570ac8ee0ed16a9f23976
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// <map> 11 12// class map 13 14// template <class InputIterator> 15// void insert(InputIterator first, InputIterator last); 16 17#include <map> 18#include <cassert> 19 20#include "../../../iterators.h" 21 22int main() 23{ 24 { 25 typedef std::map<int, double> M; 26 typedef std::pair<int, double> P; 27 P ar[] = 28 { 29 P(1, 1), 30 P(1, 1.5), 31 P(1, 2), 32 P(2, 1), 33 P(2, 1.5), 34 P(2, 2), 35 P(3, 1), 36 P(3, 1.5), 37 P(3, 2), 38 }; 39 M m; 40 m.insert(input_iterator<P*>(ar), input_iterator<P*>(ar + sizeof(ar)/sizeof(ar[0]))); 41 assert(m.size() == 3); 42 assert(m.begin()->first == 1); 43 assert(m.begin()->second == 1); 44 assert(next(m.begin())->first == 2); 45 assert(next(m.begin())->second == 1); 46 assert(next(m.begin(), 2)->first == 3); 47 assert(next(m.begin(), 2)->second == 1); 48 } 49} 50