array.zero-2说:begin()== end()是什么?
在的情况下
N == 0
,begin() == end()
==独特的价值。未指定data()
的 返回值。
这个独特的值是什么意思?这是否表示begin() == end()
的结果是一个独特的值?我不明白这是什么意思,因为布尔只能是真实的或虚假的,这不是很独特。我跑了以下测试:
#include <array>
#include <iostream>
#include <iomanip>
#include <type_traits>
int main()
{
std::array<int, 0> test;
auto b = test.begin();
auto e = test.end();
std::cout << std::boolalpha
<< (test.begin() == test.end())
<< std::is_same<bool, decltype(test.begin() == test.end())>::value
<< std::is_same<bool, decltype(b == e)>::value;
}
它所有的输出true
预期。然后我想知道对于一个非零大小的阵列它可能会有所不同:
int main()
{
std::array<int, 0> test;
std::array<int, 1> test2;
std::cout << std::boolalpha
<< std::is_same<
decltype(test.begin() == test.end()),
decltype(test2.begin() == test2.end())
>::value
<< std::is_same<
decltype(test.begin()),
decltype(test2.begin())
>::value;
}
再次都是如此。那么“独特价值”是什么意思?什么具有独特的价值?