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 // vector(const vector& v);
     14 
     15 #include <vector>
     16 #include <cassert>
     17 #include "../../test_allocator.h"
     18 
     19 template <class C>
     20 void
     21 test(const C& x)
     22 {
     23     unsigned s = x.size();
     24     C c(x);
     25     assert(c.__invariants());
     26     assert(c.size() == s);
     27     assert(c == x);
     28 }
     29 
     30 int main()
     31 {
     32     {
     33         bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0};
     34         bool* an = a + sizeof(a)/sizeof(a[0]);
     35         test(std::vector<bool>(a, an));
     36     }
     37     {
     38         std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5));
     39         std::vector<bool, test_allocator<bool> > v2 = v;
     40         assert(v2 == v);
     41         assert(v2.get_allocator() == v.get_allocator());
     42     }
     43 #ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
     44     {
     45         std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5));
     46         std::vector<bool, other_allocator<bool> > v2 = v;
     47         assert(v2 == v);
     48         assert(v2.get_allocator() == other_allocator<bool>(-2));
     49     }
     50 #endif  // _LIBCPP_HAS_NO_ADVANCED_SFINAE
     51 }
     52