我四处研究,但没有找到任何明确的答案。
如何初始化特定大小的布尔向量,全部设置为 true 或 false?
这将统一初始化向量:
const size_t SIZE = 10; // However many elements you want in the vector.
const bool initial_value = false; // All elements will be set to this value
std::vector<bool> m_allFalse(SIZE, initial_value);
常规要在开始时初始化布尔值,您可以使用以下内容:
bool temp[] = { true, false, false, true };
std::vector<bool> variousBool ( temp, temp + sizeof(tempBool) / sizeof(bool) );