this one was bad advice..

Apr 19, 2016 at 10:11pm
http://www.cplusplus.com/reference/deque/deque/erase/

just saying..maybe call the iterators "begin" and "end", or at least don't call the second one "last" when it is not the last, even if it's explained that it is not the last to erase. end, wall, stop, onebehindlast or anything like that.
Apr 20, 2016 at 5:00am
In tend to name the parameters 'begin' and 'end'.

Koenig and Moo (C++ Report, Ruminations on C++) call them 'start' and 'beyond'.

The IS consistently uses the terms 'first' and 'last'. Programmers quickly get used to the idea that 'last', as normally used in C++, is really one beyond the actual last element, and avoid writing stuff like:
1
2
3
4
5
6
if( !vec.empty() )
{
     auto first = vec.begin() ; // iterator to the first item
     auto last = vec.end() - 1 ; // iterator to the actual last element
     // ...
}
Apr 22, 2016 at 12:56pm
closed account (E0p9LyTq)
Then complain to the ISO standards committee, they were the ones who chose that wording.
Apr 22, 2016 at 1:22pm
closed account (1vD3vCM9)
You can also get all the contents of a Vector or an Array with an for each loop:
1
2
3
4
for(const auto& it : vec)
{
std::cout << it << "\n";
}
Last edited on Apr 22, 2016 at 1:22pm
Topic archived. No new replies allowed.