Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

simple_stack_vector bad range check #9

Closed
n-co opened this issue Feb 7, 2024 · 1 comment
Closed

simple_stack_vector bad range check #9

n-co opened this issue Feb 7, 2024 · 1 comment

Comments

@n-co
Copy link
Contributor

n-co commented Feb 7, 2024

range check at at functions should probably be if (idx >= size_) instead of if (idx > size_)

https://github.com/lefticus/tools/blob/332c8f58a8311aa2b7771154b826c3275df83fd0/include/lefticus/tools/simple_stack_vector.hpp#L121C1-L131C4

  [[nodiscard]] constexpr value_type &at(const std::size_t idx)
  {
    if (idx > size_) { throw std::out_of_range("index past end of stack_vector"); }
    return data_[idx];
  }


  [[nodiscard]] constexpr const value_type &at(const std::size_t idx) const
  {
    if (idx > size_) { throw std::out_of_range("index past end of stack_vector"); }
    return data_[idx];
  }
@n-co n-co mentioned this issue Feb 12, 2024
@lefticus
Copy link
Owner

Merged, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants