pau*_*l23 4 c++ visual-studio-2010 stdbind c++11
对我来说另一个令人不安的错误信息,如果我正确理解std :: bind我可以参数_1来定义一个非给定的参数吗?对?考虑以下几行:
std::function<bool(value_type, const std::string &)> 
                             func(std::bind(&Pred, _1, "name"));
Run Code Online (Sandbox Code Playgroud)
这应该有用,对吗?这将用于std :: find_if()函数,因此第一个参数应该是值类型,第二个参数应该是字符串.
然而,visual studio 2010通过以下错误消息抱怨此问题:
错误C2065:'_ 1':未声明的标识符
这很奇怪,我怎么能在视觉工作室说"嘿第一个参数没有约束".Pred是一个简单的value_type, const std::string&函数,它作为参数 - 返回一个布尔值.
Ton*_*ion 11
在你的情况下,你想要这个:
std::function<bool(value_type, const std::string &)> 
                         func(std::bind(&Pred, std::placeholders::_1, "name"));
Run Code Online (Sandbox Code Playgroud)
        |   归档时间:  |  
           
  |  
        
|   查看次数:  |  
           3317 次  |  
        
|   最近记录:  |