空元素 unordered_multiset
Elements in empty unordered_multiset
这是一个奇怪的问题,但是如果我从 unordered_multiset a 中删除元素然后尝试打印它的元素:
for (std::unordered_multiset<int>::const_iterator i(a.begin()), end(a.end()); i != end; ++i)
{
std::cout << "It's here" <<"\n";
std::cout << *i <<"\n";
}
所以,可以吗,如果这个循环不起作用,我的意思是连 "It's here" 都没有打印出来?空多重集的行为如何?
如果集合为空则 begin() == end()
为真并且永远不会进入循环。
这是一个奇怪的问题,但是如果我从 unordered_multiset a 中删除元素然后尝试打印它的元素:
for (std::unordered_multiset<int>::const_iterator i(a.begin()), end(a.end()); i != end; ++i)
{
std::cout << "It's here" <<"\n";
std::cout << *i <<"\n";
}
所以,可以吗,如果这个循环不起作用,我的意思是连 "It's here" 都没有打印出来?空多重集的行为如何?
如果集合为空则 begin() == end()
为真并且永远不会进入循环。