Filter_iterator and boost::any follow-up

I think you'll need to use something like: for(filter_itr f(i.begin(), i.end()); f != filter_itr(i.end()); ++f)
Ok, cool, I've got it working on a vector of ints.
My next question is this: I've got a vector of boost::any's, and I want to
iterate across only the boost::any's representing int's. For example:
=== CODE ===
template<typename T> struct isT {
bool operator() (const boost::any & a) const { return a.type() ==
typeid(T); } };
int main()
{
std::vectorboost::any av;
av.push_back(1);
av.push_back(std::string("hello"));
av.push_back(2);
typedef boost::filter_iterator
int_itr;
for(int_itr itr(av.begin()); itr != int_itr(av.end()); ++itr) ; } ========= Unfortunately, the above code seg faults when executed. I imagine I've probably constructed my filter_iterator incorrectly somehow. Any ideas? Thanks, --Steve Stephen Gross Case Western School of Medicine Cleveland, OH "By Grabthar's hammer, by the sons of Worvan, you shall be avenged." - Dr. Lazarus

for(int_itr itr(av.begin()); itr != int_itr(av.end()); ++itr) ; } =========
Unfortunately, the above code seg faults when executed. I imagine I've probably constructed my filter_iterator incorrectly somehow. Any ideas?
You need to replace your for-loop with the following one: for(int_itr itr(av.begin(), av.end()); itr != int_itr(av.end(), av.end()); ++itr)
participants (2)
-
Alexey Bakhvalov
-
Stephen Gross