@@ -958,4 +958,55 @@ struct MutableRACIterator {
958958 }
959959};
960960
961+ // / clang::StmtIteratorBase
962+ class ProtectedIteratorBase {
963+ protected:
964+ int value;
965+ ProtectedIteratorBase () : value(0 ) {}
966+ };
967+
968+ // / clang::StmtIteratorImpl
969+ template <typename DERIVED>
970+ class ProtectedIteratorImpl : public ProtectedIteratorBase {
971+ protected:
972+ ProtectedIteratorImpl (const ProtectedIteratorBase& RHS) : ProtectedIteratorBase(RHS) {}
973+
974+ public:
975+ using iterator_category = std::forward_iterator_tag;
976+ using value_type = int ;
977+ using difference_type = std::ptrdiff_t ;
978+ using pointer = int *;
979+ using reference = int &;
980+
981+ ProtectedIteratorImpl () = default ;
982+
983+ DERIVED& operator ++() {
984+ value++;
985+ return static_cast <DERIVED&>(*this );
986+ }
987+
988+ DERIVED operator ++(int ) {
989+ DERIVED tmp = static_cast <DERIVED&>(*this );
990+ operator ++();
991+ return tmp;
992+ }
993+
994+ friend bool operator ==(const DERIVED &LHS, const DERIVED &RHS) {
995+ return LHS.value == RHS.value ;
996+ }
997+
998+ reference operator *() const {
999+ return value;
1000+ }
1001+ };
1002+
1003+ // / StmtIterator
1004+ struct HasInheritedProtectedCopyConstructor : public ProtectedIteratorImpl <HasInheritedProtectedCopyConstructor> {
1005+ HasInheritedProtectedCopyConstructor () = default ;
1006+
1007+ private:
1008+ HasInheritedProtectedCopyConstructor (const ProtectedIteratorBase &other)
1009+ : ProtectedIteratorImpl<HasInheritedProtectedCopyConstructor>(other) {}
1010+ };
1011+
9611012#endif // TEST_INTEROP_CXX_STDLIB_INPUTS_CUSTOM_ITERATOR_H
0 commit comments