VS2008 的 boost::phoenix
使用 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() { return 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;
}
它可以编译,但 VS2008 的输出中有一些警告:
c:\boost_1_47_0\boost\phoenix\bind\detail\member_variable.hpp(54) :警告 C4180:应用于函数类型的限定符有没有意义;忽略
它来自哪里:1)代码不正确2)再次出现MS问题。 3) boost::phoenix 库表现不佳?
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() { return 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来 Boost 开发人员决定他们不会解决这个问题,也许是因为它被确定为编译器方面的错误。这是一个链接:
https://svn.boost.org/trac/boost/ticket/1097
我认为这是一般的 boost::bind() ,但我敢打赌这可能不会被修复。该票证中建议了一种解决方法。您可以尝试这样做(它只是禁用警告)。
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).