我不明白为什么这不会编译

时间:2015-09-08 05:24:25

标签: c++

    Arduino: 1.6.5 (Windows 7), Board: "Arduino Uno"

sketch_sep07d.ino: In function 'void loop()':
sketch_sep07d:158: error: a function-definition is not allowed here before '{' token
sketch_sep07d:181: error: expected '}' at end of input
sketch_sep07d:181: error: expected '}' at end of input
sketch_sep07d:181: error: expected '}' at end of input
a function-definition is not allowed here before '{' token

  This report would have more information with
  "Show verbose output during compilation"
  enabled in File > Preferences.

以下是错误:

// m_values is of type std::vector<std::pair<std::string,INIValue> >

std::find_if(this->m_values.begin(),this->m_values.end, [name](std::pair<std::string,INIValue> v)->bool { return v.first == name;});

我错过了什么?

1 个答案:

答案 0 :(得分:3)

您忘记了第二个参数的大括号。

this->m_values.end()

另外,您可能需要稍微调整一下lambda。您搜索一个值,无需复制每个向量。

[&name](const std::pair<std::string, INIValue> &v)->bool { return v.first == name;}