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#include <cstddef> 19 20#include "test_macros.h" 21#include "test_iterators.h" 22#include "min_allocator.h" 23 24template <class C, class Iterator> 25void 26test(Iterator first, Iterator last, const typename C::allocator_type& a) 27{ 28 C c(first, last, a); 29 LIBCPP_ASSERT(c.__invariants()); 30 assert(c.size() == static_cast<std::size_t>(std::distance(first, last))); 31 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) 32 assert(*i == *first); 33} 34 35int main() 36{ 37 bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; 38 bool* an = a + sizeof(a)/sizeof(a[0]); 39 { 40 std::allocator<bool> alloc; 41 test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc); 42 test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc); 43 test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc); 44 test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc); 45 test<std::vector<bool> >(a, an, alloc); 46 } 47#if TEST_STD_VER >= 11 48 { 49 min_allocator<bool> alloc; 50 test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc); 51 test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an), alloc); 52 test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an), alloc); 53 test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc); 54 test<std::vector<bool, min_allocator<bool>> >(a, an, alloc); 55 } 56#endif 57} 58