Reputation: 15814
This is inconsistent with every indexing operator in standard library. Even std::unique_ptr::operator[]
takes std::size_t
.
What's the rationale for this decision?
Upvotes: 14
Views: 418
Reputation: 11940
Probably this should be pointer interface unification. Good ol' C pointers when used as arrays accept negative indices: p[-2]
is the same as *(p - 2)
; and ptrdiff_t
is thus naturally signed.
Upvotes: 1