• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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) const;
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     const std::reverse_iterator<It> r(i);
27     std::reverse_iterator<It> rr = r - n;
28     assert(rr.base() == x);
29 }
30 
main()31 int main()
32 {
33     const char* s = "1234567890";
34     test(random_access_iterator<const char*>(s+5), 5, random_access_iterator<const char*>(s+10));
35     test(s+5, 5, s+10);
36 }
37