If the container probably contains a large number of elements, in terms of performance, you should write
for (auto p = std::begin(container); p != std::end(container); ++p) {...}
or should access the end of the container outside the loop
const auto& theEnd = std::end(container); for (auto p = std::begin(container); p != theEnd; ++p) {...}
I'm just wondering if there is std::end O (1) for containers like collections and lists, as well as vectors.
c ++
user3918490
source share