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 // UNSUPPORTED: c++03, windows, libcxx-no-debug-mode
10 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DEBUG=0
11 
12 // <list>
13 
14 // Call advance(non-bidi iterator, -1)
15 
16 #include <iterator>
17 
18 #include "check_assertion.h"
19 #include "test_iterators.h"
20 
21 int main(int, char**) {
22     int a[] = {1, 2, 3};
23 
24     bidirectional_iterator<int *> bidi(a+1);
25 	std::advance(bidi,  1);  // should work fine
26 	std::advance(bidi,  0);  // should work fine
27     std::advance(bidi, -1);  // should work fine
28 
29     forward_iterator<int *> it(a+1);
30 	std::advance(it, 1);  // should work fine
31 	std::advance(it, 0);  // should work fine
32     TEST_LIBCPP_ASSERT_FAILURE(std::advance(it, -1), "Attempt to advance(it, n) with negative n on a non-bidirectional iterator");
33 
34     return 0;
35 }
36