基于范围的for循环和迭代器
// coll为容器
for (type elem : coll)
{
...
}
被解释为:
for (auto pos = coll.begin(), end = coll.end(); end != coll.end(); ++pos)
{
type elem = *pos;
...
}
基于范围的for循环和迭代器
// coll为容器
for (type elem : coll)
{
...
}
被解释为:
for (auto pos = coll.begin(), end = coll.end(); end != coll.end(); ++pos)
{
type elem = *pos;
...
}