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 // Test nested types and data member:
15
16 // template <BidirectionalIterator Iter>
17 // class reverse_iterator {
18 // protected:
19 // Iter current;
20 // public:
21 // iterator<typename iterator_traits<Iterator>::iterator_category,
22 // typename iterator_traits<Iterator>::value_type,
23 // typename iterator_traits<Iterator>::difference_type,
24 // typename iterator_traits<Iterator>::pointer,
25 // typename iterator_traits<Iterator>::reference> {
26 // };
27
28 #include <iterator>
29 #include <type_traits>
30
31 #include "test_iterators.h"
32
33 template <class It>
34 struct find_current
35 : private std::reverse_iterator<It>
36 {
testfind_current37 void test() {++(this->current);}
38 };
39
40 template <class It>
41 void
test()42 test()
43 {
44 typedef std::reverse_iterator<It> R;
45 typedef std::iterator_traits<It> T;
46 find_current<It> q;
47 q.test();
48 static_assert((std::is_same<typename R::iterator_type, It>::value), "");
49 static_assert((std::is_same<typename R::value_type, typename T::value_type>::value), "");
50 static_assert((std::is_same<typename R::difference_type, typename T::difference_type>::value), "");
51 static_assert((std::is_same<typename R::reference, typename T::reference>::value), "");
52 static_assert((std::is_same<typename R::pointer, typename std::iterator_traits<It>::pointer>::value), "");
53 static_assert((std::is_same<typename R::iterator_category, typename T::iterator_category>::value), "");
54 }
55
main()56 int main()
57 {
58 test<bidirectional_iterator<char*> >();
59 test<random_access_iterator<char*> >();
60 test<char*>();
61 }
62