c++ - 试图找出向量中的任何元素是否为假
问题描述
只要元素仍然为假,我就需要遍历向量。我试图使用 any_of 检查是否有任何元素为假,但我一直在终端中收到错误。错误是“预期的表达式”。我的陈述有什么问题?
vector <bool> check(solarSystem.size(),false);
while(any_of(check.begin(), check.end(), [](bool k){return k == false;})
解决方案
To get this out of unanswered questions queue... your code should work if you just add a closing parenthesis:
vector <bool> check(solarSystem.size(), false);
while (any_of(check.begin(), check.end(), [](bool x) { return !x; })) {
// . . .
}
推荐阅读
- reactjs - NVDA 屏幕阅读器无法访问 React 中为视频提供的字幕
- wordpress - 在 cPanel 中找不到 Wordpress 工具包。不推荐使用 Wordpress 管理器
- javascript - 始终在反应 js antd 中的选择下拉列表顶部显示选择选项
- javascript - 在 Javascript 中拆分数组数据
- python - Django Heroku 频道实时聊天失败
- java - Java DateTime 输出格式化程序等价于 Calender.getInstance 方法
- javascript - 在 react-native 中制作瀑布效果的问题
- kernel - QEMU 如何在没有引导加载程序的情况下模拟内核?
- sql - 取消嵌套重复字段时在某列上设置不同的值
- ios - UITextView/UIView 通过使用平移手势从边缘拖动来改变框架宽度 Swift iOS