Reputation: 20056
I've got this (C++03) code, but somehow, bind
refuses to work. Any ideas why?
typedef boost::variant<int, string> Container;
std::vector<Container> v;
...
class IsBad: public boost::static_visitor<>
{
public:
typedef bool result_type;
result_type operator()(int& t) const { return i % 2; }
result_type operator()(string& s) const { return s == "foo"; }
};
IsBad isBad;
std::vector<Container>::iterator it2 =
std::find_if(it, itEnd, bind(apply_visitor(isBad, _1)));
// bool is not a class, struct or union type
Upvotes: 0
Views: 336
Reputation: 5309
You don't have to use bind
, apply_visitor(isBad)
already returns you a functor.
Upvotes: 3