@@ -286,6 +286,229 @@ struct HasTypedefIteratorTag {
286286 }
287287};
288288
289+ struct MutableRACIterator {
290+ private:
291+ int *value;
292+
293+ public:
294+ struct iterator_category : std::random_access_iterator_tag,
295+ std::output_iterator_tag {};
296+ using value_type = int ;
297+ using pointer = int *;
298+ using reference = const int &;
299+ using difference_type = int ;
300+
301+ MutableRACIterator (int *value) : value(value) {}
302+ MutableRACIterator (const MutableRACIterator &other) = default ;
303+
304+ const int &operator *() const { return *value; }
305+ int &operator *() { return *value; }
306+
307+ MutableRACIterator &operator ++() {
308+ value++;
309+ return *this ;
310+ }
311+ MutableRACIterator operator ++(int ) {
312+ auto tmp = MutableRACIterator (value);
313+ value++;
314+ return tmp;
315+ }
316+
317+ void operator +=(difference_type v) { value += v; }
318+ void operator -=(difference_type v) { value -= v; }
319+ MutableRACIterator operator +(difference_type v) const {
320+ return MutableRACIterator (value + v);
321+ }
322+ MutableRACIterator operator -(difference_type v) const {
323+ return MutableRACIterator (value - v);
324+ }
325+ friend MutableRACIterator operator +(difference_type v,
326+ const MutableRACIterator &it) {
327+ return it + v;
328+ }
329+ int operator -(const MutableRACIterator &other) const {
330+ return value - other.value ;
331+ }
332+
333+ bool operator <(const MutableRACIterator &other) const {
334+ return value < other.value ;
335+ }
336+
337+ bool operator ==(const MutableRACIterator &other) const {
338+ return value == other.value ;
339+ }
340+ bool operator !=(const MutableRACIterator &other) const {
341+ return value != other.value ;
342+ }
343+ };
344+
345+ #if __cplusplus >= 202002L
346+ struct ConstContiguousIterator {
347+ private:
348+ const int *value;
349+
350+ public:
351+ using iterator_category = std::contiguous_iterator_tag;
352+ using value_type = int ;
353+ using pointer = int *;
354+ using reference = const int &;
355+ using difference_type = int ;
356+
357+ ConstContiguousIterator (const int *value) : value(value) {}
358+ ConstContiguousIterator (const ConstContiguousIterator &other) = default ;
359+
360+ const int &operator *() const { return *value; }
361+
362+ ConstContiguousIterator &operator ++() {
363+ value++;
364+ return *this ;
365+ }
366+ ConstContiguousIterator operator ++(int ) {
367+ auto tmp = ConstContiguousIterator (value);
368+ value++;
369+ return tmp;
370+ }
371+
372+ void operator +=(difference_type v) { value += v; }
373+ void operator -=(difference_type v) { value -= v; }
374+ ConstContiguousIterator operator +(difference_type v) const {
375+ return ConstContiguousIterator (value + v);
376+ }
377+ ConstContiguousIterator operator -(difference_type v) const {
378+ return ConstContiguousIterator (value - v);
379+ }
380+ friend ConstContiguousIterator operator +(difference_type v,
381+ const ConstContiguousIterator &it) {
382+ return it + v;
383+ }
384+ int operator -(const ConstContiguousIterator &other) const {
385+ return value - other.value ;
386+ }
387+
388+ bool operator <(const ConstContiguousIterator &other) const {
389+ return value < other.value ;
390+ }
391+
392+ bool operator ==(const ConstContiguousIterator &other) const {
393+ return value == other.value ;
394+ }
395+ bool operator !=(const ConstContiguousIterator &other) const {
396+ return value != other.value ;
397+ }
398+ };
399+
400+ struct HasCustomContiguousIteratorTag {
401+ private:
402+ const int *value;
403+
404+ public:
405+ struct CustomTag : std::contiguous_iterator_tag {};
406+ using iterator_category = CustomTag;
407+ using value_type = int ;
408+ using pointer = int *;
409+ using reference = const int &;
410+ using difference_type = int ;
411+
412+ HasCustomContiguousIteratorTag (const int *value) : value(value) {}
413+ HasCustomContiguousIteratorTag (const HasCustomContiguousIteratorTag &other) =
414+ default ;
415+
416+ const int &operator *() const { return *value; }
417+
418+ HasCustomContiguousIteratorTag &operator ++() {
419+ value++;
420+ return *this ;
421+ }
422+ HasCustomContiguousIteratorTag operator ++(int ) {
423+ auto tmp = HasCustomContiguousIteratorTag (value);
424+ value++;
425+ return tmp;
426+ }
427+
428+ void operator +=(difference_type v) { value += v; }
429+ void operator -=(difference_type v) { value -= v; }
430+ HasCustomContiguousIteratorTag operator +(difference_type v) const {
431+ return HasCustomContiguousIteratorTag (value + v);
432+ }
433+ HasCustomContiguousIteratorTag operator -(difference_type v) const {
434+ return HasCustomContiguousIteratorTag (value - v);
435+ }
436+ friend HasCustomContiguousIteratorTag
437+ operator +(difference_type v, const HasCustomContiguousIteratorTag &it) {
438+ return it + v;
439+ }
440+ int operator -(const HasCustomContiguousIteratorTag &other) const {
441+ return value - other.value ;
442+ }
443+
444+ bool operator <(const HasCustomContiguousIteratorTag &other) const {
445+ return value < other.value ;
446+ }
447+
448+ bool operator ==(const HasCustomContiguousIteratorTag &other) const {
449+ return value == other.value ;
450+ }
451+ bool operator !=(const HasCustomContiguousIteratorTag &other) const {
452+ return value != other.value ;
453+ }
454+ };
455+
456+ struct MutableContiguousIterator {
457+ private:
458+ int *value;
459+
460+ public:
461+ using iterator_category = std::contiguous_iterator_tag;
462+ using value_type = int ;
463+ using pointer = int *;
464+ using reference = const int &;
465+ using difference_type = int ;
466+
467+ MutableContiguousIterator (int *value) : value(value) {}
468+ MutableContiguousIterator (const MutableContiguousIterator &other) = default ;
469+
470+ const int &operator *() const { return *value; }
471+ int &operator *() { return *value; }
472+
473+ MutableContiguousIterator &operator ++() {
474+ value++;
475+ return *this ;
476+ }
477+ MutableContiguousIterator operator ++(int ) {
478+ auto tmp = MutableContiguousIterator (value);
479+ value++;
480+ return tmp;
481+ }
482+
483+ void operator +=(difference_type v) { value += v; }
484+ void operator -=(difference_type v) { value -= v; }
485+ MutableContiguousIterator operator +(difference_type v) const {
486+ return MutableContiguousIterator (value + v);
487+ }
488+ MutableContiguousIterator operator -(difference_type v) const {
489+ return MutableContiguousIterator (value - v);
490+ }
491+ friend MutableContiguousIterator
492+ operator +(difference_type v, const MutableContiguousIterator &it) {
493+ return it + v;
494+ }
495+ int operator -(const MutableContiguousIterator &other) const {
496+ return value - other.value ;
497+ }
498+
499+ bool operator <(const MutableContiguousIterator &other) const {
500+ return value < other.value ;
501+ }
502+
503+ bool operator ==(const MutableContiguousIterator &other) const {
504+ return value == other.value ;
505+ }
506+ bool operator !=(const MutableContiguousIterator &other) const {
507+ return value != other.value ;
508+ }
509+ };
510+ #endif
511+
289512// MARK: Types that are not actually iterators
290513
291514struct HasNoIteratorCategory {
@@ -916,62 +1139,6 @@ struct InputOutputConstIterator {
9161139 }
9171140};
9181141
919- struct MutableRACIterator {
920- private:
921- int *value;
922-
923- public:
924- struct iterator_category : std::random_access_iterator_tag,
925- std::output_iterator_tag {};
926- using value_type = int ;
927- using pointer = int *;
928- using reference = const int &;
929- using difference_type = int ;
930-
931- MutableRACIterator (int *value) : value(value) {}
932- MutableRACIterator (const MutableRACIterator &other) = default ;
933-
934- const int &operator *() const { return *value; }
935- int &operator *() { return *value; }
936-
937- MutableRACIterator &operator ++() {
938- value++;
939- return *this ;
940- }
941- MutableRACIterator operator ++(int ) {
942- auto tmp = MutableRACIterator (value);
943- value++;
944- return tmp;
945- }
946-
947- void operator +=(difference_type v) { value += v; }
948- void operator -=(difference_type v) { value -= v; }
949- MutableRACIterator operator +(difference_type v) const {
950- return MutableRACIterator (value + v);
951- }
952- MutableRACIterator operator -(difference_type v) const {
953- return MutableRACIterator (value - v);
954- }
955- friend MutableRACIterator operator +(difference_type v,
956- const MutableRACIterator &it) {
957- return it + v;
958- }
959- int operator -(const MutableRACIterator &other) const {
960- return value - other.value ;
961- }
962-
963- bool operator <(const MutableRACIterator &other) const {
964- return value < other.value ;
965- }
966-
967- bool operator ==(const MutableRACIterator &other) const {
968- return value == other.value ;
969- }
970- bool operator !=(const MutableRACIterator &other) const {
971- return value != other.value ;
972- }
973- };
974-
9751142// / clang::StmtIteratorBase
9761143class ProtectedIteratorBase {
9771144protected:
0 commit comments