boost::phoenix with VS2008
Simple example using boost::phoenix:
#include <vector>
#include <algorithm>
#include <boost/phoenix.hpp>
namespace ph = boost::phoenix;
namespace place = boost::phoenix::placeholders;
struct A
{
int val_;
explicit A(int i) : val_(i) {}
int foo() { r开发者_如何学Pythoneturn val_;}
};
int main()
{
std::vector<A> coll;
coll.push_back(A(2));
coll.push_back(A(4));
coll.push_back(A(5));
coll.push_back(A(7));
std::vector<A>::const_iterator cit;
cit = std::find_if(coll.begin(), coll.end(), ph::bind(&A::foo, place::_1) % 2 == 1);
int val = (*cit).val_;
return 0;
}
It compiles but there are some warnings at the output of VS2008:
c:\boost_1_47_0\boost\phoenix\bind\detail\member_variable.hpp(54) : warning C4180: qualifier applied to function type has no meaning; ignored
Where it came from: 1) incorrectness in code 2) again MS problems. 3) boost::phoenix library not doing well?
It looks like the Boost devs decided that they weren't going to workaround this, perhaps since it was determined to be an error on the part of the compiler. Here's a link:
https://svn.boost.org/trac/boost/ticket/1097
I think this is for general boost::bind(), but I'd bet that this probably won't be fixed. There's a workaround suggested in that ticket. You might try that (it just disables the warning).
精彩评论