construct_iter_iter_alloc.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// <vector> 11// vector<bool> 12 13// template <class InputIter> vector(InputIter first, InputIter last, 14// const allocator_type& a); 15 16#include <vector> 17#include <cassert> 18 19#include "../../iterators.h" 20 21template <class C, class Iterator> 22void 23test(Iterator first, Iterator last, const typename C::allocator_type& a) 24{ 25 C c(first, last, a); 26 assert(c.__invariants()); 27 assert(c.size() == std::distance(first, last)); 28 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) 29 assert(*i == *first); 30} 31 32int main() 33{ 34 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; 35 bool* an = a + sizeof(a)/sizeof(a[0]); 36 std::allocator<bool> alloc; 37 test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc); 38 test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc); 39 test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc); 40 test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc); 41 test<std::vector<bool> >(a, an, alloc); 42} 43