Use of C++ container iterator with negative 1 index in X3 examples
"Chris Mileto" <[email protected]> Sat, 9 Jun 2018 20:58:28 -0400
| Newsgroups | gmane.comp.parsers.spirit.general |
|---|---|
| Message-ID | <[email protected]> |
In the Calc9 example code file vm.cpp (and in many other X3 examples) the syntax: "stack_ptr[-1] = some_value;" is used, where stack_ptr is defined as std::vector<int>::iterator stack_ptr. According to the standard as I understand it, iterator indexing begins at zero. I can see that it compiles and executes at least for my Microsoft Visual Studio 2017 compiler, but is the use of a negative index valid C++ syntax? If so what does it mean? Thanks for any insight, Chris ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot