Does filter_iterator work for maps?
Hi,
I don't see a reason for filter_iterator not to work with map
iterators.
However, the program below doesn't work.
I get a compiler error "Cannot generate template specialization
from 'make_filter_iterator
At 3:01 AM +0000 3/15/02, rodrigo_braz wrote:
#include <map> #include <ostream>
#include <iostream>
#include "boost/iterator_adaptors.hpp" #include <algorithm>
using namespace std; using namespace boost;
struct pair_is_active { bool operator()(const pair
& p) { return 0 < p.second; } }; ostream& operator<<(ostream& o, pair
p) { return o << "(" << p.first << ", " << p.second << ")"; } int main() { map
m; m[0] = 10; m[1] = 15; m[2] = 0; m[3] = 13; copy(boost::make_filter_iterator
(m.begin, m.end()),
copy(boost::make_filter_iterator
boost::make_filter_iterator
(m.end(), m.end()), ostream_iterator >(cout,",")); return 0; }
-- Jon Kalb Kalb@LibertySoft.com
--- In Boost-Users@y..., Jon Kalb
At 3:01 AM +0000 3/15/02, rodrigo_braz wrote:
copy(boost::make_filter_iterator
(m.begin, m.end ()), copy(boost::make_filter_iterator
(m.begin(), m.end ()),
Ouch. Ok, sorry about that. Actually my main problem with this
iterator is in the code below:
#include <vector>
#include "boost/iterator_adaptors.hpp"
using namespace std;
using namespace boost;
struct is_active {
bool operator()(int p) { return 0 < p; }
};
struct A
{
typedef
filter_iterator_generator
On 3/15/02 4:37 PM, "rodrigo_braz"
--- In Boost-Users@y..., Jon Kalb
wrote: Actually my main problem with this iterator is in the code below: #include <vector> #include "boost/iterator_adaptors.hpp"
using namespace std; using namespace boost;
struct is_active { bool operator()(int p) { return 0 < p; } };
struct A { typedef filter_iterator_generator
::type active_iterator;
CodeWarrior doesn't complain about this code, but I think that it should be:
typedef typename
filter_iterator_generator
On Fri, 15 Mar 2002, Jon Kalb wrote:
kalb> > struct A
kalb> > {
kalb> > typedef
kalb> > filter_iterator_generator
Hi Rodrigo,
The above program compiles OK for me with g++ 2.95.2. What compiler are
you using? (there's a good chance the compiler error you are getting is a
bug in your compiler, not in your code or in the Boost code).
Cheers,
Jeremy
On Sat, 16 Mar 2002, rodrigo_braz wrote:
rodrig> --- In Boost-Users@y..., Jon Kalb
participants (3)
-
Jeremy Siek
-
Jon Kalb
-
rodrigo_braz