Repository navigation
refactor(butil): Adopt native move semantics - #3685
Open
darion-yaphet wants to merge 1 commit into
Open
darion-yaphet wants to merge 1 commit into
darion-yaphet wants to merge 1 commit into
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replace C++03 move emulation with native rvalue references and
std::moveforscoped_ptr,ScopedVector,ScopedGeneric,File, andScopedFILE.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
Risk and Rollback
This introduces source and binary compatibility changes:
butil/move.h,MOVE_ONLY_TYPE_FOR_CPP_03,Pass(), andPassAs(). Downstream callers must migrate to native move operations.Filemove signatures to acceptFile&&. Downstream shared-library consumers must rebuild.ScopedVectormove 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; discardingstd::move(owner)does not release resources.Rollback requires reverting the corresponding downstream API migrations and rebuilding affected binaries.