211f0ee1be
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@124508 91177308-0d34-0410-b5e6-96231b3b80d8
73 lines
1.8 KiB
C++
73 lines
1.8 KiB
C++
//===----------------------------------------------------------------------===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is dual licensed under the MIT and the University of Illinois Open
|
|
// Source Licenses. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// <vector>
|
|
|
|
// iterator begin();
|
|
// iterator end();
|
|
// const_iterator begin() const;
|
|
// const_iterator end() const;
|
|
// const_iterator cbegin() const;
|
|
// const_iterator cend() const;
|
|
|
|
#include <vector>
|
|
#include <cassert>
|
|
#include <iterator>
|
|
|
|
int main()
|
|
{
|
|
{
|
|
typedef int T;
|
|
typedef std::vector<T> C;
|
|
C c;
|
|
C::iterator i = c.begin();
|
|
C::iterator j = c.end();
|
|
assert(std::distance(i, j) == 0);
|
|
assert(i == j);
|
|
}
|
|
{
|
|
typedef int T;
|
|
typedef std::vector<T> C;
|
|
const C c;
|
|
C::const_iterator i = c.begin();
|
|
C::const_iterator j = c.end();
|
|
assert(std::distance(i, j) == 0);
|
|
assert(i == j);
|
|
}
|
|
{
|
|
typedef int T;
|
|
typedef std::vector<T> C;
|
|
C c;
|
|
C::const_iterator i = c.cbegin();
|
|
C::const_iterator j = c.cend();
|
|
assert(std::distance(i, j) == 0);
|
|
assert(i == j);
|
|
assert(i == c.end());
|
|
}
|
|
{
|
|
typedef int T;
|
|
typedef std::vector<T> C;
|
|
const T t[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
|
C c(std::begin(t), std::end(t));
|
|
C::iterator i = c.begin();
|
|
assert(*i == 0);
|
|
++i;
|
|
assert(*i == 1);
|
|
*i = 10;
|
|
assert(*i == 10);
|
|
assert(std::distance(c.begin(), c.end()) == 10);
|
|
}
|
|
{
|
|
typedef int T;
|
|
typedef std::vector<T> C;
|
|
C::iterator i;
|
|
C::const_iterator j;
|
|
}
|
|
}
|