代码示例:
list<int> mylist{10, 20, 30, 40};
auto p = mylist.end();
while (true)
{
p++;
if (p == mylist.end()) // skip sentinel
continue;
cout << *p << endl;
}
Run Code Online (Sandbox Code Playgroud)
我想知道,从标准(C ++ 17,n4810)角度来看,这段代码多少合法?我在寻找与上述示例相关的双向迭代器要求,但是没有运气。
我的问题是:
是否可以通过end(),是实现细节还是标准要求?