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 // <iterator>
11 
12 // reverse_iterator
13 
14 // requires RandomAccessIterator<Iter>
15 //   reverse_iterator& operator-=(difference_type n);
16 
17 #include <iterator>
18 #include <cassert>
19 
20 #include "test_iterators.h"
21 
22 template <class It>
23 void
test(It i,typename std::iterator_traits<It>::difference_type n,It x)24 test(It i, typename std::iterator_traits<It>::difference_type n, It x)
25 {
26     std::reverse_iterator<It> r(i);
27     std::reverse_iterator<It>& rr = r -= n;
28     assert(r.base() == x);
29     assert(&rr == &r);
30 }
31 
main()32 int main()
33 {
34     const char* s = "1234567890";
35     test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
36     test(s+5, 5, s+10);
37 }
38