1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 // <vector>
10 
11 // Increment iterator past end.
12 
13 // REQUIRES: has-unix-headers
14 // UNSUPPORTED: libcxx-no-debug-mode, c++03
15 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=1
16 
17 #include <vector>
18 #include <cassert>
19 
20 #include "check_assertion.h"
21 #include "min_allocator.h"
22 
23 int main(int, char**) {
24   {
25     typedef int T;
26     typedef std::vector<T> C;
27     C c(1);
28     C::iterator i = c.begin();
29     ++i;
30     assert(i == c.end());
31     TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
32   }
33 
34   {
35     typedef int T;
36     typedef std::vector<T, min_allocator<T> > C;
37     C c(1);
38     C::iterator i = c.begin();
39     ++i;
40     assert(i == c.end());
41     TEST_LIBCPP_ASSERT_FAILURE(++i, "Attempted to increment a non-incrementable iterator");
42   }
43 
44   return 0;
45 }
46