Skip to content

Preserve VLA source capacity for unequal-allocator moves - #218

Draft
thirtytwobits wants to merge 1 commit into
mainfrom
codex/issue-211-preserve-source-capacity
Draft

thirtytwobits wants to merge 1 commit into
mainfrom
codex/issue-211-preserve-source-capacity

Conversation

@thirtytwobits

Copy link
Copy Markdown
Member

Allocator-extended move construction with unequal allocators currently frees the source buffer after relocating its elements. Retain that allocation and capacity while emptying the source, matching unequal-allocator move assignment. This permits source reuse without another allocation; callers can explicitly release storage with shrink_to_fit().

Equal-allocator moves still transfer storage. Destination allocation sizing and the existing move-assignment policy of releasing an insufficient destination buffer before replacement are preserved. Document the successful-move contract and the separate exception guarantees, and remove no-op allocator assignment calls.

Regression coverage checks ordinary elements, packed bool, empty reserved sources, both move-assignment capacity branches, source reuse and explicit release, copy fallback, move-only elements, allocator destruction hooks, and successful retry after allocation failure. The new constructor-retention tests failed against the original implementation before the fix.

Validation:

  • All 10 VLA suites passed with GCC C++14 and Clang C++17 in Debug and ReleaseEP.
  • All 215 cases in the move-capacity, exception-safety, and copy/move suites passed with Clang C++17 ASan/UBSan and leak detection.
  • Prescribed Toolshed clang-format checks and git diff --check passed.
  • API documentation built successfully; 13 warnings remain in unchanged type_traits_ext.hpp and unbounded_variant.hpp.

Fixes #211.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

VLA move construction with unequal allocators should preserve source capacity

1 participant