Skip to content

refactor(butil): Adopt native move semantics - #3685

Open
darion-yaphet wants to merge 1 commit into
apache:masterfrom
darion-yaphet:refactor/butil-standard-move
Open

darion-yaphet wants to merge 1 commit into
apache:masterfrom
darion-yaphet:refactor/butil-standard-move

Conversation

@darion-yaphet

Copy link
Copy Markdown
Contributor

Summary

Replace C++03 move emulation with native rvalue references and std::move for scoped_ptr, ScopedVector, ScopedGeneric, File, and ScopedFILE.

Update ownership-transfer call sites, remove the legacy move header and helpers, and add regression coverage for ownership transfer, self-move, resource cleanup, and custom deleters. Document downstream migration in docs/en/cpp14_move.md.

Testing

  • Both affected CMake targets rebuilt successfully on macOS.
  • All 57 targeted tests passed.

Risk and Rollback

This introduces source and binary compatibility changes:

  • Remove butil/move.h, MOVE_ONLY_TYPE_FOR_CPP_03, Pass(), and PassAs(). Downstream callers must migrate to native move operations.
  • Change exported File move signatures to accept File&&. Downstream shared-library consumers must rebuild.
  • ScopedVector move assignment now destroys the destination's previous elements and leaves the source empty, instead of swapping their contents.

Discarded Pass() calls must become explicit cleanup operations; discarding std::move(owner) does not release resources.

Rollback requires reverting the corresponding downstream API migrations and rebuilding affected binaries.

Replace C++03 move emulation with native rvalue references and std::move for butil resource owners. Update callers, add ownership-transfer regression coverage, and document downstream migration.

BREAKING CHANGE: Remove butil/move.h, MOVE_ONLY_TYPE_FOR_CPP_03, Pass(), and PassAs(). File move signatures now take File&&; downstream shared-library consumers must rebuild.
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.

1 participant