-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In
{,Intrusive}SharedPtr<T>
, use plain assignment instead of
`riegeli::Reset()` for assigning `T` from `T&&`. `riegeli::Reset()` is designed for using methods which are equivalent to assigning an object constructed from other constructor arguments. If the constructor argument is just `T&&`, there is nothing to construct before the assignment, and the idiomatic way to customize this is assignment, not `Reset()`. Also, simplify `IntrusiveSharedPtr::ResetImpl()` by introducing a helper predicate, like in `SharedPtr::ResetImpl()`. `riegeli::Reset()` continues to be used for assigning `T` from `Initializer<T>`. This dispatches to methods which use other `Reset()` variants depending on how the `Initializer<T>` was constructed, e.g. for `Initializer<T>` constructed from `MakerType<Args..>` this calls `Reset(T&, Args...)`, which can be more efficient. Sadly, the constraint for usability of `riegeli::Reset(T&, Initializer<T>)` must continue to be `std::move_assignable<T>`, because even if e.g. `MakerType<Args...>` supported `riegeli::Reset()` under weaker constraints, type erasure in `Initializer<T>` requires all ways of constructing `Initializer<T>` to support `riegeli::Reset()`. In particular for `Initializer<T>` constructed from `T&&` this requires `std::move_assignable<T>`. There not enough usages of `riegeli::Reset()` directly with `MakerType` or `MakerTypeFor` (not through `Initializer`) to warrant weakening their constraints (which could be done by introducing a `SupportsReset` predicate and using it for them, instead of the current `std::constructible<T, Args...>` and `std::is_move_assignable<T>). In summary, `riegeli::Reset()` should be viewed as an optimization of assigning a constructed object, not a generalization to support new ways of replacing the state of non-move-assignable types. PiperOrigin-RevId: 692199724
- Loading branch information
Showing
5 changed files
with
29 additions
and
33 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
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
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