|
Boost Users : |
From: Stephen Gross (sgross_at_[hidden])
Date: 2005-09-13 11:47:22
>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::vector<boost::any> av;
av.push_back(1);
av.push_back(std::string("hello"));
av.push_back(2);
typedef boost::filter_iterator<isT<int>, std::vector<boost::any>::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
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net