1d4fa0381SMarshall Clow //===----------------------------------------------------------------------===//
2d4fa0381SMarshall Clow //
357b08b09SChandler Carruth // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
457b08b09SChandler Carruth // See https://llvm.org/LICENSE.txt for license information.
557b08b09SChandler Carruth // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6d4fa0381SMarshall Clow //
7d4fa0381SMarshall Clow //===----------------------------------------------------------------------===//
8d4fa0381SMarshall Clow 
9d4fa0381SMarshall Clow // <iterator>
10d4fa0381SMarshall Clow 
11d4fa0381SMarshall Clow // struct iterator_traits
12d4fa0381SMarshall Clow // {
13d4fa0381SMarshall Clow // };
14d4fa0381SMarshall Clow 
15d4fa0381SMarshall Clow #include <iterator>
16d4fa0381SMarshall Clow #include "test_macros.h"
17d4fa0381SMarshall Clow 
18d4fa0381SMarshall Clow struct A {};
19d4fa0381SMarshall Clow struct NotAnIteratorEmpty {};
20d4fa0381SMarshall Clow 
21d4fa0381SMarshall Clow struct NotAnIteratorNoDifference
22d4fa0381SMarshall Clow {
23d4fa0381SMarshall Clow //     typedef int                       difference_type;
24d4fa0381SMarshall Clow     typedef A                         value_type;
25d4fa0381SMarshall Clow     typedef A*                        pointer;
26d4fa0381SMarshall Clow     typedef A&                        reference;
27d4fa0381SMarshall Clow     typedef std::forward_iterator_tag iterator_category;
28d4fa0381SMarshall Clow };
29d4fa0381SMarshall Clow 
30d4fa0381SMarshall Clow struct NotAnIteratorNoValue
31d4fa0381SMarshall Clow {
32d4fa0381SMarshall Clow     typedef int                       difference_type;
33d4fa0381SMarshall Clow //     typedef A                         value_type;
34d4fa0381SMarshall Clow     typedef A*                        pointer;
35d4fa0381SMarshall Clow     typedef A&                        reference;
36d4fa0381SMarshall Clow     typedef std::forward_iterator_tag iterator_category;
37d4fa0381SMarshall Clow };
38d4fa0381SMarshall Clow 
39d4fa0381SMarshall Clow struct NotAnIteratorNoPointer
40d4fa0381SMarshall Clow {
41d4fa0381SMarshall Clow     typedef int                       difference_type;
42d4fa0381SMarshall Clow     typedef A                         value_type;
43d4fa0381SMarshall Clow //     typedef A*                        pointer;
44d4fa0381SMarshall Clow     typedef A&                        reference;
45d4fa0381SMarshall Clow     typedef std::forward_iterator_tag iterator_category;
46d4fa0381SMarshall Clow };
47d4fa0381SMarshall Clow 
48d4fa0381SMarshall Clow struct NotAnIteratorNoReference
49d4fa0381SMarshall Clow {
50d4fa0381SMarshall Clow     typedef int                       difference_type;
51d4fa0381SMarshall Clow     typedef A                         value_type;
52d4fa0381SMarshall Clow     typedef A*                        pointer;
53d4fa0381SMarshall Clow //    typedef A&                        reference;
54d4fa0381SMarshall Clow     typedef std::forward_iterator_tag iterator_category;
55d4fa0381SMarshall Clow };
56d4fa0381SMarshall Clow 
57d4fa0381SMarshall Clow struct NotAnIteratorNoCategory
58d4fa0381SMarshall Clow {
59d4fa0381SMarshall Clow     typedef int                       difference_type;
60d4fa0381SMarshall Clow     typedef A                         value_type;
61d4fa0381SMarshall Clow     typedef A*                        pointer;
62d4fa0381SMarshall Clow     typedef A&                        reference;
63d4fa0381SMarshall Clow //     typedef std::forward_iterator_tag iterator_category;
64d4fa0381SMarshall Clow };
65d4fa0381SMarshall Clow 
main(int,char **)662df59c50SJF Bastien int main(int, char**)
67d4fa0381SMarshall Clow {
68d4fa0381SMarshall Clow     {
69d4fa0381SMarshall Clow     typedef std::iterator_traits<NotAnIteratorEmpty> T;
70c3e15b3cSArthur O'Dwyer     typedef T::difference_type   DT; // expected-error-re {{no type named 'difference_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
71c3e15b3cSArthur O'Dwyer     typedef T::value_type        VT; // expected-error-re {{no type named 'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
72c3e15b3cSArthur O'Dwyer     typedef T::pointer           PT; // expected-error-re {{no type named 'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
73c3e15b3cSArthur O'Dwyer     typedef T::reference         RT; // expected-error-re {{no type named 'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
74c3e15b3cSArthur O'Dwyer     typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
75d4fa0381SMarshall Clow     }
76d4fa0381SMarshall Clow 
77d4fa0381SMarshall Clow     {
78d4fa0381SMarshall Clow     typedef std::iterator_traits<NotAnIteratorNoDifference> T;
79c3e15b3cSArthur O'Dwyer     typedef T::difference_type   DT; // expected-error-re {{no type named 'difference_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
80c3e15b3cSArthur O'Dwyer     typedef T::value_type        VT; // expected-error-re {{no type named 'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
81c3e15b3cSArthur O'Dwyer     typedef T::pointer           PT; // expected-error-re {{no type named 'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
82c3e15b3cSArthur O'Dwyer     typedef T::reference         RT; // expected-error-re {{no type named 'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
83c3e15b3cSArthur O'Dwyer     typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
84d4fa0381SMarshall Clow     }
85d4fa0381SMarshall Clow 
86d4fa0381SMarshall Clow     {
87d4fa0381SMarshall Clow     typedef std::iterator_traits<NotAnIteratorNoValue> T;
88c3e15b3cSArthur O'Dwyer     typedef T::difference_type   DT; // expected-error-re {{no type named 'difference_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
89c3e15b3cSArthur O'Dwyer     typedef T::value_type        VT; // expected-error-re {{no type named 'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
90c3e15b3cSArthur O'Dwyer     typedef T::pointer           PT; // expected-error-re {{no type named 'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
91c3e15b3cSArthur O'Dwyer     typedef T::reference         RT; // expected-error-re {{no type named 'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
92c3e15b3cSArthur O'Dwyer     typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
93d4fa0381SMarshall Clow     }
94*9f01ac3bSzoecarver #if TEST_STD_VER <= 17 || !defined(__cpp_lib_concepts)
95d4fa0381SMarshall Clow     {
96d4fa0381SMarshall Clow     typedef std::iterator_traits<NotAnIteratorNoPointer> T;
97c3e15b3cSArthur O'Dwyer     typedef T::difference_type   DT; // expected-error-re {{no type named 'difference_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
98c3e15b3cSArthur O'Dwyer     typedef T::value_type        VT; // expected-error-re {{no type named 'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
99c3e15b3cSArthur O'Dwyer     typedef T::pointer           PT; // expected-error-re {{no type named 'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
100c3e15b3cSArthur O'Dwyer     typedef T::reference         RT; // expected-error-re {{no type named 'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
101c3e15b3cSArthur O'Dwyer     typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
102d4fa0381SMarshall Clow     }
103*9f01ac3bSzoecarver #endif // TEST_STD_VER <= 17 || !defined(__cpp_lib_concepts)
104d4fa0381SMarshall Clow     {
105d4fa0381SMarshall Clow     typedef std::iterator_traits<NotAnIteratorNoReference> T;
106c3e15b3cSArthur O'Dwyer     typedef T::difference_type   DT; // expected-error-re {{no type named 'difference_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
107c3e15b3cSArthur O'Dwyer     typedef T::value_type        VT; // expected-error-re {{no type named 'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
108c3e15b3cSArthur O'Dwyer     typedef T::pointer           PT; // expected-error-re {{no type named 'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
109c3e15b3cSArthur O'Dwyer     typedef T::reference         RT; // expected-error-re {{no type named 'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
110c3e15b3cSArthur O'Dwyer     typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
111d4fa0381SMarshall Clow     }
112d4fa0381SMarshall Clow 
113d4fa0381SMarshall Clow     {
114d4fa0381SMarshall Clow     typedef std::iterator_traits<NotAnIteratorNoCategory> T;
115c3e15b3cSArthur O'Dwyer     typedef T::difference_type   DT; // expected-error-re {{no type named 'difference_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
116c3e15b3cSArthur O'Dwyer     typedef T::value_type        VT; // expected-error-re {{no type named 'value_type' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
117c3e15b3cSArthur O'Dwyer     typedef T::pointer           PT; // expected-error-re {{no type named 'pointer' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
118c3e15b3cSArthur O'Dwyer     typedef T::reference         RT; // expected-error-re {{no type named 'reference' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
119c3e15b3cSArthur O'Dwyer     typedef T::iterator_category CT; // expected-error-re {{no type named 'iterator_category' in 'std:{{.*}}:iterator_traits<{{.+}}>}}
120d4fa0381SMarshall Clow     }
1212df59c50SJF Bastien 
1222df59c50SJF Bastien   return 0;
123d4fa0381SMarshall Clow }
124