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 | // vector(const vector& v); |
| 14 | |
| 15 | #include <vector> |
| 16 | #include <cassert> |
Marshall Clow | 1b92188 | 2013-12-03 00:18:10 +0000 | [diff] [blame] | 17 | #include "test_allocator.h" |
Marshall Clow | 061d0cc | 2013-11-26 20:58:02 +0000 | [diff] [blame] | 18 | #include "min_allocator.h" |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 19 | |
| 20 | template <class C> |
| 21 | void |
| 22 | test(const C& x) |
| 23 | { |
| 24 | unsigned s = x.size(); |
| 25 | C c(x); |
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() == s); |
| 28 | assert(c == x); |
| 29 | } |
| 30 | |
| 31 | int main() |
| 32 | { |
| 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>(a, an)); |
| 37 | } |
| 38 | { |
| 39 | std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5)); |
| 40 | std::vector<bool, test_allocator<bool> > v2 = v; |
| 41 | assert(v2 == v); |
| 42 | assert(v2.get_allocator() == v.get_allocator()); |
| 43 | } |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 44 | #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 45 | { |
| 46 | std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5)); |
| 47 | std::vector<bool, other_allocator<bool> > v2 = v; |
| 48 | assert(v2 == v); |
| 49 | assert(v2.get_allocator() == other_allocator<bool>(-2)); |
| 50 | } |
Dan Albert | 1d4a1ed | 2016-05-25 22:36:09 -0700 | [diff] [blame^] | 51 | #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE |
| 52 | #if __cplusplus >= 201103L |
Howard Hinnant | 2c39cbe | 2013-06-27 19:35:32 +0000 | [diff] [blame] | 53 | { |
| 54 | bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; |
| 55 | bool* an = a + sizeof(a)/sizeof(a[0]); |
| 56 | test(std::vector<bool, min_allocator<bool>>(a, an)); |
| 57 | } |
| 58 | { |
| 59 | std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>()); |
| 60 | std::vector<bool, min_allocator<bool> > v2 = v; |
| 61 | assert(v2 == v); |
| 62 | assert(v2.get_allocator() == v.get_allocator()); |
| 63 | } |
| 64 | #endif |
Howard Hinnant | bc8d3f9 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 65 | } |