C++ 编译C++;密码?

C++ 编译C++;密码?,c++,eclipse,c++11,lambda,C++,Eclipse,C++11,Lambda,编译这段代码时,我收到一个错误: void Lift::AddDestFloors(const vector<Person>& persons, vector<int>& fplan, int lift_pos) { for (auto &person : persons) { int dest_flr = person.de

编译这段代码时,我收到一个错误:

void Lift::AddDestFloors(const vector<Person>& persons,
                         vector<int>& fplan,
                         int lift_pos) {
    for (auto &person : persons) {
        int dest_flr = person.dest_floor;
        if (std::find_if(fplan.begin(), fplan.end(),
                         [dest_flr] (const Person& person) -> bool {
                             return person.dest_floor == dest_flr;
                         }) == fplan.end()) {
            InsertToMasterFlightPlan(person.dest_floor, fplan);
        }
    }
}
void Lift::adddest楼层(施工向量和人员),
矢量与平面图,
内部升降机(位置){
用于(自动和人员:人员){
int dest_flr=人员。dest_楼层;
if(std::find_if(fplan.begin(),fplan.end(),
[dest_flr](const Person&Person)->bool{
return person.dest\u floor==dest\u flr;
})==fplan.end()){
插入MasterFlightPlan(person.dest_楼层,fplan);
}
}
}
错误消息:

调用“”时不匹配(Lift::AddDestFloors(const std::vector&), std::vector&,int)::u lambda0)(int&)' LiftSim第208行,外部位置: c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h c/c++问题 我的环境是:

  • 视窗7
  • 日食(开普勒)
  • Mingw 4.8.1

为什么会出现此错误?

此错误意味着使用
int
作为参数调用
类型的某些值(Lift::adddestmools(const std::vector&,std::vector&,int):\uu lambda0)
,但不能使用
int
值调用对象。(例如,如果lambda接受
bool
,则不能使用
int
作为参数调用它)

代码中唯一的lambda是
find_if
[dest_flr](const Person&Person)->bool{return Person.dest_floor==dest_flr;})的参数


您正在
fplan
上调用
find\u if
fplan
的元素类型为
int
,因此lambda也应该采用
int
,而不是
Person

你的意思大概是
std::find_if(persons.begin(),persons.end(),…
?你的lambda取的是
Person
而不是
int
。不,不是,那只是lambda的位置。 no match for call to '(Lift::AddDestFloors(const std::vector&, std::vector&, int)::__lambda0) (int&)' LiftSim line 208, external location: c:\mingw\lib\gcc\mingw32\4.8.1\include\c++\bits\stl_algo.h C/C++ Problem