首页 > 解决方案 > Python 的“all”函数的 C++ 等价物是什么?

问题描述

检查 bool 向量(或 bool 数组)的所有值是否都是 C++ 的方法是什么true (只使用 1 行,如 Python)

在 Python 中,我可以做到

a = [true, true, true, false]
b = [true, true, true]

print(all(a)) # it will print false
print(all(b)) # it will print true

我可以通过创建一个函数来检查它,但我想知道它是否可以通过使用内置库来完成。

标签: pythonc++arrays

解决方案


推荐阅读