C++ 是否有一个单输入、二进制输出的stdlib或boost函数可以绑定? bool all_ok=boost::algorithm::all_of(info.begin(),threadInfo.end(),[&](std::pair const&p){return p.second.am_ok;});
上面是我试图从中删除c++11的一行代码(如果您必须知道的话,为了与我正在集成的应用程序兼容)。我希望在不定义当前方法外部的函数的情况下替换lambdaC++ 是否有一个单输入、二进制输出的stdlib或boost函数可以绑定? bool all_ok=boost::algorithm::all_of(info.begin(),threadInfo.end(),[&](std::pair const&p){return p.second.am_ok;});,c++,boost,C++,Boost,上面是我试图从中删除c++11的一行代码(如果您必须知道的话,为了与我正在集成的应用程序兼容)。我希望在不定义当前方法外部的函数的情况下替换lambda 我的问题是,如何利用boost::bind来表示接受单个输入并返回布尔值的函数&绑定?如果您真的想使用boost::bind来实现这一点,它看起来会像这样: bool all_ok = boost::algorithm::all_of(info.begin(), threadInfo.end(), [&](std::pair<st
我的问题是,如何利用boost::bind来表示接受单个输入并返回布尔值的函数&绑定?如果您真的想使用
boost::bind
来实现这一点,它看起来会像这样:
bool all_ok = boost::algorithm::all_of(info.begin(), threadInfo.end(), [&](std::pair<std::string, Info> const &p){ return p.second.am_ok; });
这是怎么回事:(为了替换部分lambda,还有更多的东西要做)
boost::bind(&Info::am_ok, boost::bind(&std::pair<std::string, Info>::second, _1));
struct is_ok
{
typedef bool result_type;
result_type operator() (std::pair<std::string, Info> const &p) const
{
return p.second.am_ok;
}
};