blob: 94e6801825d8134413b14e5315a7084779455c03 [file] [log] [blame]
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnantf5256e12010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00004//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantbc8d3f92010-05-11 19:42:16 +00007//
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
Marshall Clow83e2c4d2013-01-05 03:21:01 +000018#include "test_iterators.h"
Marshall Clow061d0cc2013-11-26 20:58:02 +000019#include "min_allocator.h"
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000020
21template <class C, class Iterator>
22void
23test(Iterator first, Iterator last)
24{
25 C c(first, last);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070026 assert(c.__invariants());
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000027 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 test<std::vector<bool> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
37 test<std::vector<bool> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
38 test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
39 test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
40 test<std::vector<bool> >(a, an);
Dan Albert1d4a1ed2016-05-25 22:36:09 -070041#if __cplusplus >= 201103L
Howard Hinnant2c39cbe2013-06-27 19:35:32 +000042 test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an));
43 test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an));
44 test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an));
45 test<std::vector<bool, min_allocator<bool>> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an));
46 test<std::vector<bool, min_allocator<bool>> >(a, an);
47#endif
Howard Hinnantbc8d3f92010-05-11 19:42:16 +000048}