public member function
<array>
std::array::empty
constexpr bool empty() noexcept;
Test whether array is empty
返回一個boolvalue indicating whether the array container is empty, i.e. whether its size is0.
This function does not modify the content of the array in any way. To clear the content of an array object, use array::fill.
返回值
trueif the array size is0, false否則為 false。
This is aconstexpr.
示例
1 2 3 4 5 6 7 8 9 10 11 12
|
// array::empty
#include <iostream>
#include <array>
int main ()
{
std::array<int,0> first;
std::array<int,5> second;
std::cout << "first " << (first.empty() ? "is empty" : "is not empty") << '\n';
std::cout << "second " << (second.empty() ? "is empty" : "is not empty") << '\n';
return 0;
}
|
輸出
first is empty
second is not empty
|
資料競爭
不訪問任何包含的元素:併發訪問或修改它們是安全的。