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 // struct iterator_traits 13 // { 14 // }; 15 16 #include <iterator> 17 #include "test_macros.h" 18 19 struct A {}; 20 struct NotAnIteratorEmpty {}; 21 22 struct NotAnIteratorNoDifference 23 { 24 // typedef int difference_type; 25 typedef A value_type; 26 typedef A* pointer; 27 typedef A& reference; 28 typedef std::forward_iterator_tag iterator_category; 29 }; 30 31 struct NotAnIteratorNoValue 32 { 33 typedef int difference_type; 34 // typedef A value_type; 35 typedef A* pointer; 36 typedef A& reference; 37 typedef std::forward_iterator_tag iterator_category; 38 }; 39 40 struct NotAnIteratorNoPointer 41 { 42 typedef int difference_type; 43 typedef A value_type; 44 // typedef A* pointer; 45 typedef A& reference; 46 typedef std::forward_iterator_tag iterator_category; 47 }; 48 49 struct NotAnIteratorNoReference 50 { 51 typedef int difference_type; 52 typedef A value_type; 53 typedef A* pointer; 54 // typedef A& reference; 55 typedef std::forward_iterator_tag iterator_category; 56 }; 57 58 struct NotAnIteratorNoCategory 59 { 60 typedef int difference_type; 61 typedef A value_type; 62 typedef A* pointer; 63 typedef A& reference; 64 // typedef std::forward_iterator_tag iterator_category; 65 }; 66 main()67int main() 68 { 69 { 70 typedef std::iterator_traits<NotAnIteratorEmpty> T; 71 typedef T::difference_type DT; // expected-error-re {{no type named 'difference_type' in 'std::__1::iterator_traits<{{.+}}>}} 72 typedef T::value_type VT; // expected-error-re {{no type named 'value_type' in 'std::__1::iterator_traits<{{.+}}>}} 73 typedef T::pointer PT; // expected-error-re {{no type named 'pointer' in 'std::__1::iterator_traits<{{.+}}>}} 74 typedef T::reference RT; // expected-error-re {{no type named 'reference' in 'std::__1::iterator_traits<{{.+}}>}} 75 typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std::__1::iterator_traits<{{.+}}>}} 76 } 77 78 { 79 typedef std::iterator_traits<NotAnIteratorNoDifference> T; 80 typedef T::difference_type DT; // expected-error-re {{no type named 'difference_type' in 'std::__1::iterator_traits<{{.+}}>}} 81 typedef T::value_type VT; // expected-error-re {{no type named 'value_type' in 'std::__1::iterator_traits<{{.+}}>}} 82 typedef T::pointer PT; // expected-error-re {{no type named 'pointer' in 'std::__1::iterator_traits<{{.+}}>}} 83 typedef T::reference RT; // expected-error-re {{no type named 'reference' in 'std::__1::iterator_traits<{{.+}}>}} 84 typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std::__1::iterator_traits<{{.+}}>}} 85 } 86 87 { 88 typedef std::iterator_traits<NotAnIteratorNoValue> T; 89 typedef T::difference_type DT; // expected-error-re {{no type named 'difference_type' in 'std::__1::iterator_traits<{{.+}}>}} 90 typedef T::value_type VT; // expected-error-re {{no type named 'value_type' in 'std::__1::iterator_traits<{{.+}}>}} 91 typedef T::pointer PT; // expected-error-re {{no type named 'pointer' in 'std::__1::iterator_traits<{{.+}}>}} 92 typedef T::reference RT; // expected-error-re {{no type named 'reference' in 'std::__1::iterator_traits<{{.+}}>}} 93 typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std::__1::iterator_traits<{{.+}}>}} 94 } 95 96 { 97 typedef std::iterator_traits<NotAnIteratorNoPointer> T; 98 typedef T::difference_type DT; // expected-error-re {{no type named 'difference_type' in 'std::__1::iterator_traits<{{.+}}>}} 99 typedef T::value_type VT; // expected-error-re {{no type named 'value_type' in 'std::__1::iterator_traits<{{.+}}>}} 100 typedef T::pointer PT; // expected-error-re {{no type named 'pointer' in 'std::__1::iterator_traits<{{.+}}>}} 101 typedef T::reference RT; // expected-error-re {{no type named 'reference' in 'std::__1::iterator_traits<{{.+}}>}} 102 typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std::__1::iterator_traits<{{.+}}>}} 103 } 104 105 { 106 typedef std::iterator_traits<NotAnIteratorNoReference> T; 107 typedef T::difference_type DT; // expected-error-re {{no type named 'difference_type' in 'std::__1::iterator_traits<{{.+}}>}} 108 typedef T::value_type VT; // expected-error-re {{no type named 'value_type' in 'std::__1::iterator_traits<{{.+}}>}} 109 typedef T::pointer PT; // expected-error-re {{no type named 'pointer' in 'std::__1::iterator_traits<{{.+}}>}} 110 typedef T::reference RT; // expected-error-re {{no type named 'reference' in 'std::__1::iterator_traits<{{.+}}>}} 111 typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std::__1::iterator_traits<{{.+}}>}} 112 } 113 114 { 115 typedef std::iterator_traits<NotAnIteratorNoCategory> T; 116 typedef T::difference_type DT; // expected-error-re {{no type named 'difference_type' in 'std::__1::iterator_traits<{{.+}}>}} 117 typedef T::value_type VT; // expected-error-re {{no type named 'value_type' in 'std::__1::iterator_traits<{{.+}}>}} 118 typedef T::pointer PT; // expected-error-re {{no type named 'pointer' in 'std::__1::iterator_traits<{{.+}}>}} 119 typedef T::reference RT; // expected-error-re {{no type named 'reference' in 'std::__1::iterator_traits<{{.+}}>}} 120 typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std::__1::iterator_traits<{{.+}}>}} 121 } 122 } 123