I've got this template:
template<typename C,class F>
class filtered_cont{
C& container;
F filter;
class const_iterator{
//my iterator implementation
}
const_iterator begin(){
//...
}
}
C- container and F is filter. I'd like to ask how to implement my own begin() method that it will return first valid element. I got something like this, but I get errors
const_iterator begin() const{
for (const_iterator it=cont.begin(); it!=const_iterator(); it++) {
if(pred(*it)) return it;
}
return const_iterator();
}
I think the wrong part is it=cont.begin(), but I don't really know how to get begin() iterator.
Error:
no viable conversion from 'iterator' (aka '__list_iterator<value_type, __void_pointer>') to 'filter_view<std::__1::list<unsigned char,
std::__1::allocator<unsigned char> >, is_even>::const_iterator