Ind*_*ant 5 c++ iterator list std
那么递增或递减end()迭代器是在标准中定义的吗?在linux上,begin()实现为end()++.
#include <list>
#include <iostream>
int main()
{
std::list<int> numbers;
for (int i = 0; i < 10; i++)
numbers.push_back(i);
auto it = numbers.begin();
int count = 3;
while (count)
{
std::cout << *it++;
if (it == numbers.end())
{
++it; // is this ok ???
--count;
std::cout << '\n';
}
}
}
Run Code Online (Sandbox Code Playgroud)
那么每个平台的输出总是一样的吗?
输出:
0123456789
0123456789
0123456789
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1609 次 |
最近记录: |