Add replacements for various STD types#58
Conversation
…pm), `std::expected` (Expected.cppm) & `std::optional` (Optional.cppm)
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (4)
📝 WalkthroughWalkthroughAdds exported C++20 modules for owning dynamic arrays, optional and expected value states, and non-owning spans. The aggregate containers module now re-exports all four modules. ChangesCore container modules
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 7
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@Engine/cpp/Runtime/Core/Containers/Array.cppm`:
- Around line 48-54: Update Reserve to reject negative newCapacity and itemSize
values, and validate that itemSize is nonzero and newCapacity does not exceed
the maximum representable size divided by itemSize before evaluating newCapacity
* itemSize. Return the appropriate error for invalid or overflowing inputs while
preserving the existing allocation path for valid capacities.
- Around line 209-240: Update Array::Push overloads and Emplace to preserve
arguments that reference existing elements across internal.GrowCapacity, since
growth may relocate and free the source storage before construction. Stage
aliased lvalue, rvalue, and Emplace arguments before growth, or change the
growth sequence so insertion occurs before releasing the old buffer, while
preserving existing error handling and insertion behavior.
- Around line 167-183: Update Array::operator=(Array&&) to transfer
other.internal.allocator to the destination before or alongside stealing its
buffer, size, and capacity, ensuring the moved-to array frees the allocation
with the original allocator; reset the moved-from allocator as appropriate for
its empty state.
- Around line 109-123: Update RelocateElements to handle exceptions from T’s
move constructor: require and enforce nothrow move construction, or catch
failures to destroy all already-constructed destination elements and release the
newly allocated buffer before rethrowing. Preserve the existing trivially
copyable memcpy path.
- Around line 271-274: Update Array::end() and its const overload in
Engine/cpp/Runtime/Core/Containers/Array.cppm (lines 271-274) to return Data()
directly when internal.size is zero, avoiding null-pointer arithmetic while
preserving normal end-pointer calculation for non-empty arrays. Apply the same
change to Span end iterators in Engine/cpp/Runtime/Core/Containers/Span.cppm
(lines 37-38), returning buffer directly when count is zero.
In `@Engine/cpp/Runtime/Core/Containers/Optional.cppm`:
- Around line 85-93: Update Optional’s move assignment operator near
Engine/cpp/Runtime/Core/Containers/Optional.cppm:85-93 to use T’s nothrow
move-constructibility, matching its placement-new reconstruction. Also update
Expected’s move constructor near
Engine/cpp/Runtime/Core/Containers/Expected.cppm:51-56 so its noexcept condition
requires both T and E to be nothrow move-constructible.
In `@Engine/cpp/Runtime/Core/Containers/Span.cppm`:
- Around line 19-20: Update the Span(T* ptr, isize size) constructor to reject
negative sizes, and update Subspan to accept only length == -1 or nonnegative
lengths. Validate requested lengths against count - offset rather than offset +
length, while preserving existing bounds behavior and preventing invalid
negative-sized spans.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 0e660228-67ca-4706-b153-aad71fa56ab5
📒 Files selected for processing (5)
Engine/cpp/Runtime/Core/Containers/Array.cppmEngine/cpp/Runtime/Core/Containers/Containers.cppmEngine/cpp/Runtime/Core/Containers/Expected.cppmEngine/cpp/Runtime/Core/Containers/Optional.cppmEngine/cpp/Runtime/Core/Containers/Span.cppm
std::vector,std::span,std::optional&std::expectedSummary by CodeRabbit
Optionalfor values that may be absent, including default-value access and reset support.ExpectedandUnexpectedfor representing successful results or errors.Spanviews for contiguous data, including subrange access.