Skip to content

Commit

Permalink
pw_containers: Make Vector::at() use size_t
Browse files Browse the repository at this point in the history
Unfortunately the size_type being different from size_t AND having the
size() and max() functions return size_t makes it difficult to NOT use a
size_t index when accessing the Vector. So, let's swing the other way
and take a size_t index when accessing the Vector.

Change-Id: Iea5d8600ae16294095f1c1085122485f0269066a
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/215859
Reviewed-by: Wyatt Hepler <[email protected]>
Lint: Lint 🤖 <[email protected]>
Commit-Queue: Carlos Chinchilla <[email protected]>
  • Loading branch information
ChinchillaWithGoggles authored and CQ Bot Account committed Jun 13, 2024
1 parent 160897b commit 9b6ab56
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pw_containers/public/pw_containers/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,20 +307,20 @@ class Vector<T, vector_impl::kGeneric> {

// Access

reference at(size_type index) {
reference at(size_t index) {
PW_ASSERT(index < size());
return data()[index];
}
const_reference at(size_type index) const {
const_reference at(size_t index) const {
PW_ASSERT(index < size());
return data()[index];
}

reference operator[](size_type index) {
reference operator[](size_t index) {
PW_DASSERT(index < size());
return data()[index];
}
const_reference operator[](size_type index) const {
const_reference operator[](size_t index) const {
PW_DASSERT(index < size());
return data()[index];
}
Expand Down

0 comments on commit 9b6ab56

Please sign in to comment.