Search code examples
c++11rangeiunknown

C++11 Strange notation [0:size())


Am I to understand from

Stroutrup C++ Programming Language - Invariants

that the notation above is a range initializer or is this interpretive instruction to convey mathematically that the Vector class array range is between 0 and some predetermined size?

Should I even be using this book because it contains errors such as accessing a struct member from a variable of that struct using . instead of ->?


Solution

  • It's a half-closed interval. He's saying the index to a vector must be in the range of 0 up to but not including the vector's size. So 0 would be a valid index (assuming the vector is not empty), but size() would not. This is not a code example.