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