#include <iostream>
#include <iterator>

struct csforward_iterator : 
    std::iterator<std::bidirectional_iterator_tag, const char, void> {

    csforward_iterator( pointer ptr = nullptr ) : p( ptr ) {}
    
    csforward_iterator& operator++()  { ++p; return *this; }
    csforward_iterator operator++(int) { auto t = *this; ++p; return t; }
    
    csforward_iterator& operator--()  { --p; return *this; }
    csforward_iterator operator--(int) { auto t = *this; --p; return t; }
    
    bool operator==( csforward_iterator o ) { 
        return p == o.p or ( p ? not ( o.p or *p ) : *o.p ); 
    }
    bool operator!=( csforward_iterator o ) { return not operator==( o ); }
    
    reference operator*() const { return *p; }
private:
    pointer p;
};


int main() {
    std::copy( csforward_iterator( "foobar" ), csforward_iterator(), std::ostream_iterator<char>(std::cout) );
    std::cout << std::endl;
}