Boost logo

Boost :

From: John Torjo (john.lists_at_[hidden])
Date: 2003-12-08 19:40:35


Robert Ramey wrote:

> 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);
> }
> };
>
> main(){
> typedef boost::filter_iterator<
> remove_whitespace_predicate,
> std::list<char>::const_iterator
> > fi;
>
> std::list<char> clist;
> std::list<char> olist;
> std::copy(
> fi(clist.begin(), clist.end()),
> fi(), // ? what goes here
> std::back_inserter(olist)
> );
> }
you could always use rtl ;)

Or,

     std::copy(
         fi(clist.begin(), clist.end()),
         fi( clist.end(), clist.end()), // ? what goes here
         std::back_inserter(olist)
     );

Best,
John

>
> ? 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
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>
> .
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk