forked from Bitcoin-ABC/bitcoin-abc
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make class CAutoFile move-assignable and move-constructible
Summary --- We make `CAutoFile` be move-assignable and move-constructible. Upon moving, ownership is transferred from the moved-from object (which becomes `.IsNull()`) to the moved-to object. The moved-to object is then responsible for closing the file (if any) on destruction. This is similar to how `std::unique_ptr` works and is a common C++ idiom. Since this class is semantically a unique_ptr that has extra serialization stream smarts, it might be useful to be able to move-assign and/or move-construct it, and return it from e.g. utility functions. The motivation for this change is that this move-assign/move-construct behavior may be needed in a future MR. A unit test was added to test this new feature of the class. Test Plan --- - `ninja all check-all`
- Loading branch information
Showing
2 changed files
with
84 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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