refactor: modernize pixel_sum to C++20 and migrate headers to .hpp - #1
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c9bc0b5adc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| PixelSum<T, S>::PixelSum(const T* buffer, int width, int height) | ||
| : PixelSum(std::span<const T>(buffer, static_cast<std::size_t>(width) * static_cast<std::size_t>(height)), width, height) |
There was a problem hiding this comment.
Validate dimensions before constructing span
The delegating pointer constructor builds std::span<const T>(buffer, width*height) before checking whether width/height are in range, so invalid inputs (e.g., negative or oversized dimensions that are supposed to throw) now violate std::span's valid-range precondition and trigger undefined behavior before the runtime error path executes. This is a regression from the previous implementation, which validated dimensions first; please move validation ahead of span construction or avoid delegating through a span for raw-pointer inputs.
Useful? React with 👍 / 👎.
No description provided.