Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | f5256e1 | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | b64f8b0 | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | |
Marshall Clow | 83e2c4d | 2013-01-05 03:21:01 +0000 | [diff] [blame] | 18 | #include "test_iterators.h" |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 19 | #include "min_allocator.h" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 20 | |
| 21 | template <class C, class Iterator> |
| 22 | void |
| 23 | test(Iterator first, Iterator last) |
| 24 | { |
| 25 | C c(first, last); |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 26 | assert(c.__invariants()); |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 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 | |
| 32 | int 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 Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 41 | #if __cplusplus >= 201103L |
Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 +0000 | [diff] [blame] | 42 | 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 Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 48 | } |