@@ -1055,28 +1055,75 @@ void Lambda(int x, const String& s) {
1055
1055
lambda_inits (6 );
1056
1056
}
1057
1057
1058
- template <typename T>
1059
- struct vector {
1058
+ namespace std {
1059
+ template <class T >
1060
+ struct remove_const { typedef T type; };
1061
+
1062
+ template <class T >
1063
+ struct remove_const <const T> { typedef T type; };
1064
+
1065
+ // `remove_const_t<T>` removes any `const` specifier from `T`
1066
+ template <class T >
1067
+ using remove_const_t = typename remove_const<T>::type;
1068
+
1069
+ struct ptrdiff_t ;
1070
+
1071
+ template <class I > struct iterator_traits ;
1072
+
1073
+ template <class Category ,
1074
+ class value_type ,
1075
+ class difference_type = ptrdiff_t ,
1076
+ class pointer_type = value_type*,
1077
+ class reference_type = value_type&>
1060
1078
struct iterator {
1061
- T* p;
1062
- iterator& operator ++();
1063
- T& operator *() const ;
1079
+ typedef Category iterator_category;
1080
+
1081
+ iterator ();
1082
+ iterator (iterator<Category, remove_const_t <value_type> > const &other); // non-const -> const conversion constructor
1083
+
1084
+ iterator &operator ++();
1085
+ iterator operator ++(int );
1086
+ iterator &operator --();
1087
+ iterator operator --(int );
1088
+ bool operator ==(iterator other) const ;
1089
+ bool operator !=(iterator other) const ;
1090
+ reference_type operator *() const ;
1091
+ pointer_type operator ->() const ;
1092
+ iterator operator +(int );
1093
+ iterator operator -(int );
1094
+ iterator &operator +=(int );
1095
+ iterator &operator -=(int );
1096
+ int operator -(iterator);
1097
+ reference_type operator [](int );
1098
+ };
1099
+
1100
+ struct input_iterator_tag {};
1101
+ struct forward_iterator_tag : public input_iterator_tag {};
1102
+ struct bidirectional_iterator_tag : public forward_iterator_tag {};
1103
+ struct random_access_iterator_tag : public bidirectional_iterator_tag {};
1104
+
1105
+ struct output_iterator_tag {};
1064
1106
1065
- bool operator !=(iterator right) const ;
1107
+ template <typename T>
1108
+ struct vector {
1109
+ vector (T);
1110
+ ~vector ();
1111
+
1112
+ using iterator = std::iterator<random_access_iterator_tag, T>;
1113
+ using const_iterator = std::iterator<random_access_iterator_tag, const T>;
1114
+
1115
+ iterator begin () const ;
1116
+ iterator end () const ;
1066
1117
};
1067
1118
1068
- vector (T);
1069
- ~vector ();
1070
- iterator begin () const ;
1071
- iterator end () const ;
1072
- };
1119
+ template <typename T>
1120
+ bool operator ==(typename vector<T>::iterator left, typename vector<T>::iterator right);
1121
+ template <typename T>
1122
+ bool operator !=(typename vector<T>::iterator left, typename vector<T>::iterator right);
1073
1123
1074
- template <typename T>
1075
- bool operator ==(typename vector<T>::iterator left, typename vector<T>::iterator right);
1076
- template <typename T>
1077
- bool operator !=(typename vector<T>::iterator left, typename vector<T>::iterator right);
1124
+ }
1078
1125
1079
- void RangeBasedFor (const vector<int >& v) {
1126
+ void RangeBasedFor (const std:: vector<int >& v) {
1080
1127
for (int e : v) {
1081
1128
if (e > 0 ) {
1082
1129
continue ;
@@ -2151,21 +2198,21 @@ void initialization_with_destructor(bool b, char c) {
2151
2198
}
2152
2199
2153
2200
ClassWithDestructor x;
2154
- for (vector<ClassWithDestructor> ys (x); ClassWithDestructor y : ys)
2201
+ for (std:: vector<ClassWithDestructor> ys (x); ClassWithDestructor y : ys)
2155
2202
y.set_x (' a' );
2156
2203
2157
- for (vector<ClassWithDestructor> ys (x); ClassWithDestructor y : ys) {
2204
+ for (std:: vector<ClassWithDestructor> ys (x); ClassWithDestructor y : ys) {
2158
2205
y.set_x (' a' );
2159
2206
if (y.get_x () == ' b' )
2160
2207
return ;
2161
2208
}
2162
2209
2163
- for (vector<int > ys (1 ); int y : ys) {
2210
+ for (std:: vector<int > ys (1 ); int y : ys) {
2164
2211
if (y == 1 )
2165
2212
return ;
2166
2213
}
2167
2214
2168
- for (vector<ClassWithDestructor> ys (x); ClassWithDestructor y : ys) {
2215
+ for (std:: vector<ClassWithDestructor> ys (x); ClassWithDestructor y : ys) {
2169
2216
ClassWithDestructor z1;
2170
2217
ClassWithDestructor z2;
2171
2218
}
@@ -2243,7 +2290,7 @@ void ForDestructors() {
2243
2290
String s2;
2244
2291
}
2245
2292
2246
- for (String s : vector<String>(String (" hello" ))) {
2293
+ for (String s : std:: vector<String>(String (" hello" ))) {
2247
2294
String s2;
2248
2295
}
2249
2296
0 commit comments