These aren’t C++ specific terms, they are general mathmatics terms.
[] and () denote whether the range is inclusive/exclusive of the endpoint:
- [ includes the endpoint
- ( excludes the endpoint
- [] = ‘Closed’, includes both endpoints
- () = ‘Open’, excludes both endpoints
- [) and (] are both ‘half-open’, and include only one endpoint
Most C++ for-loops cover a half-open range (you include the first element: e.g for int i=0;
, but exclude the final element: i < foo
, not i ≤ foo
)
This great answer is courtesy of jam.
Pingback: Did You Know That Slices in Go Can Take Three Indices? | Golang Project Structure