Boost logo

Boost :

From: Robert Ramey (ramey_at_[hidden])
Date: 2003-12-08 14:31:14

I have a question regarding the filter_iterator which
is illustrated by the following small program:

#include <list>
#include <algorithm>
#include <boost/config.hpp>
#include <boost/compatibility/cpp_c_headers/cctype>
#include <boost/iterator/filter_iterator.hpp>

struct remove_whitespace_predicate
    char operator()(char t){
        return ! std::isspace(t);

    typedef boost::filter_iterator<
> fi;

    std::list<char> clist;
    std::list<char> olist;
        fi(clist.begin(), clist.end()),
        fi(), // ? what goes here

? what goes here ?
fi() doesn't work because base() != base(clist.end())
fi(clist.end()) crashes because the constructor for
fi dereferences its iterator argument which is not always
possible when the iterator corresponds to one more than
the end of the list.

Does anyone have something to recommend?

Robert Ramey

Boost list run by bdawes at, gregod at, cpdaniel at, john at