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 
     12 // iterator       begin();
     13 // iterator       end();
     14 // const_iterator begin()  const;
     15 // const_iterator end()    const;
     16 // const_iterator cbegin() const;
     17 // const_iterator cend()   const;
     18 
     19 #include <vector>
     20 #include <cassert>
     21 #include <iterator>
     22 
     23 #include "min_allocator.h"
     24 
     25 int main()
     26 {
     27     {
     28         typedef bool T;
     29         typedef std::vector<T> C;
     30         C c;
     31         C::iterator i = c.begin();
     32         C::iterator j = c.end();
     33         assert(std::distance(i, j) == 0);
     34         assert(i == j);
     35     }
     36     {
     37         typedef bool T;
     38         typedef std::vector<T> C;
     39         const C c;
     40         C::const_iterator i = c.begin();
     41         C::const_iterator j = c.end();
     42         assert(std::distance(i, j) == 0);
     43         assert(i == j);
     44     }
     45     {
     46         typedef bool T;
     47         typedef std::vector<T> C;
     48         C c;
     49         C::const_iterator i = c.cbegin();
     50         C::const_iterator j = c.cend();
     51         assert(std::distance(i, j) == 0);
     52         assert(i == j);
     53         assert(i == c.end());
     54     }
     55     {
     56         typedef bool T;
     57         typedef std::vector<T> C;
     58         C::iterator i;
     59         C::const_iterator j;
     60     }
     61 #if __cplusplus >= 201103L
     62     {
     63         typedef bool T;
     64         typedef std::vector<T, min_allocator<T>> C;
     65         C c;
     66         C::iterator i = c.begin();
     67         C::iterator j = c.end();
     68         assert(std::distance(i, j) == 0);
     69         assert(i == j);
     70     }
     71     {
     72         typedef bool T;
     73         typedef std::vector<T, min_allocator<T>> C;
     74         const C c;
     75         C::const_iterator i = c.begin();
     76         C::const_iterator j = c.end();
     77         assert(std::distance(i, j) == 0);
     78         assert(i == j);
     79     }
     80     {
     81         typedef bool T;
     82         typedef std::vector<T, min_allocator<T>> C;
     83         C c;
     84         C::const_iterator i = c.cbegin();
     85         C::const_iterator j = c.cend();
     86         assert(std::distance(i, j) == 0);
     87         assert(i == j);
     88         assert(i == c.end());
     89     }
     90     {
     91         typedef bool T;
     92         typedef std::vector<T, min_allocator<T>> C;
     93         C::iterator i;
     94         C::const_iterator j;
     95     }
     96 #endif
     97 #if _LIBCPP_STD_VER > 11
     98     { // N3644 testing
     99         std::vector<bool>::iterator ii1{}, ii2{};
    100         std::vector<bool>::iterator ii4 = ii1;
    101         std::vector<bool>::const_iterator cii{};
    102         assert ( ii1 == ii2 );
    103         assert ( ii1 == ii4 );
    104 
    105         assert (!(ii1 != ii2 ));
    106 
    107         assert ( (ii1 == cii ));
    108         assert ( (cii == ii1 ));
    109         assert (!(ii1 != cii ));
    110         assert (!(cii != ii1 ));
    111         assert (!(ii1 <  cii ));
    112         assert (!(cii <  ii1 ));
    113         assert ( (ii1 <= cii ));
    114         assert ( (cii <= ii1 ));
    115         assert (!(ii1 >  cii ));
    116         assert (!(cii >  ii1 ));
    117         assert ( (ii1 >= cii ));
    118         assert ( (cii >= ii1 ));
    119         assert (cii - ii1 == 0);
    120         assert (ii1 - cii == 0);
    121     }
    122 #endif
    123 }
    124