Skip to content

Commit

Permalink
Merge pull request #10 from n-co/fix_range_check
Browse files Browse the repository at this point in the history
Fix range check
  • Loading branch information
lefticus committed Mar 18, 2024
2 parents 11ec954 + 4f4ada8 commit e033dca
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/lefticus/tools/simple_stack_string.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ struct basic_simple_stack_string

[[nodiscard]] constexpr value_type &at(const std::size_t idx)
{
if (idx > size_) { throw std::out_of_range("index past end of stack_vector"); }
if (idx >= size_) { throw std::out_of_range("index past end of stack_string"); }
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"); }
if (idx >= size_) { throw std::out_of_range("index past end of stack_string"); }
return data_[idx];
}

Expand Down
4 changes: 2 additions & 2 deletions include/lefticus/tools/simple_stack_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,13 @@ template<typename Contained, std::size_t Capacity> struct simple_stack_vector

[[nodiscard]] constexpr value_type &at(const std::size_t idx)
{
if (idx > size_) { throw std::out_of_range("index past end of stack_vector"); }
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"); }
if (idx >= size_) { throw std::out_of_range("index past end of stack_vector"); }
return data_[idx];
}

Expand Down

0 comments on commit e033dca

Please sign in to comment.