Skip to content

Add pf17 uninitialized_move polyfill - #209

Closed
thirtytwobits wants to merge 2 commits into
mainfrom
codex/pf17-uninitialized-move
Closed

thirtytwobits wants to merge 2 commits into
mainfrom
codex/pf17-uninitialized-move

Conversation

@thirtytwobits

Copy link
Copy Markdown
Member

CETL's C++14 polyfills lack the sequential std::uninitialized_move algorithm needed for the construction/rollback work in #37. Add cetl::pf17::uninitialized_move in cetl/pf17/memory.hpp, with standard move semantics, exact cleanup of successfully constructed destination objects on failure, and caller-owned storage.

Follow the existing pf17 header, namespace, Doxygen, exception-guard, and facade conventions. cetl::uninitialized_move selects the polyfill in C++14 and the standard implementation in C++17 and newer. An internal construction/rollback helper accepts construction and destruction callbacks for subsequent allocator-aware VLA integration. It records each successful construction before advancing the input iterator, so an iterator exception also destroys the most recently constructed object.

This branch is based directly on main, independently of #207 and #208. VLA integration remains in #37.

Closes #206.

Validation:

  • Dedicated CETLVaSt tests cover empty/single/multiple elements, move-only and copy-only values, nontrivial lifetimes, single-pass input and forward destination iterators, construction and input-iterator failures, original exception propagation, overloaded address-of, and class-specific placement new. Success and construction-failure cases also run against the standard algorithm in C++17 and newer.
  • GCC 13.4 and Clang 22.1.8: C++14/17/20/23, each in Debug, Release, DebugEP, and ReleaseEP (32 passing configurations, including exceptions disabled).
  • Clang C++14 ASan/UBSan: all 17 tests pass.
  • Existing C++14 string-view and memory-resource suites: all 65 tests pass.
  • Formatting and git diff --check pass locally.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation satisfies the documented API, rollback guarantees, facade conventions, and test requirements.

Review effort: Balanced
Findings: None

What changed in this PR

Adds the C++14-compatible uninitialized_move polyfill required for future exception-safe VLA construction.

Changes:

  • Implements move construction with precise rollback on failure.
  • Adds C++14/C++17 facade selection.
  • Adds comprehensive algorithm and failure-path tests.
File Description
include/​cetl/​pf17/​memory.hpp Implements the polyfill and reusable rollback helper.
include/​cetl/​pf17/​cetlpf.hpp Exposes the polyfill or standard implementation.
cetlvast/​suites/​unittest/​test_pf17_memory.cpp Tests semantics, iterators, lifetimes, and failures.
cetlvast/​suites/​unittest/​CMakeLists.txt Registers the new test suite.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@thirtytwobits
thirtytwobits deleted the codex/pf17-uninitialized-move branch October 1, 2026 23:34
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.

Implement std::uninitialized_move as a pf17 polyfill

2 participants