Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "std_lib_facilities.h"//from B. Stroustrup's site
- using Line = vector<char>;
- class Text_iterator {
- list<Line>::iterator ln; //points to lines
- Line::iterator pos; //points to characters
- public:
- Text_iterator(list<Line>::iterator ll, Line::iterator pp)
- :ln{ll}, pos{pp} { }
- char& operator*() { return *pos; }
- Text_iterator& operator++();
- bool operator==(const Text_iterator& other) const
- { return ln==other.ln && pos==other.pos; }
- bool operator!=(const Text_iterator& other) const
- { return !(*this==other); }
- };
- Text_iterator& Text_iterator::operator++()
- {
- ++pos;
- if (pos==(*ln).end()) {
- ++ln;
- pos = (*ln).begin();
- }
- return *this;
- }
- Text_iterator find_txt(Text_iterator first, Text_iterator last, const string& s)
- {
- if (s.size()==0) return last;// canβt find an empty stringchar first_char = s[0];
- char first_char = s[0];
- while (true) {
- auto p = find(first, last, first_char); //<------------the PROBLEM!!!!!!
- //if (p==last || match(p,last,s)) return p;
- //first = ++p;// look at the next character
- }
- }
- void ex6()
- {
- ;
- }
- int main()
- {
- ex6();
- }
- template<typename _Iterator, typename _Predicate>
- inline _Iterator
- __find_if(_Iterator __first, _Iterator __last, _Predicate __pred)
- {
- return __find_if(__first, __last, __pred,
- std::__iterator_category(__first)); //this is line #162 in stl_algo.h
- }
- template<typename _Iter>
- inline typename iterator_traits<_Iter>::iterator_category
- __iterator_category(const _Iter&)//this is line #204 in stl_iterator_base_types.h
- { return typename iterator_traits<_Iter>::iterator_category(); }
- namespace std {
- template<>
- struct iterator_traits<Text_iterator> {
- typedef ptrdiff_t difference_type;
- typedef char value_type;
- typedef char* pointer;
- typedef char& reference;
- typedef input_iterator_tag iterator_category;
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement