Skip to content

Commit

Permalink
Fix RiegeliToExternalStorage(SharedPtr<const T>*) and
Browse files Browse the repository at this point in the history
`RiegeliToExternalStorage(IntrusiveSharedPtr<const T>*)` build by adding
a `const_cast`.

PiperOrigin-RevId: 648716816
  • Loading branch information
QrczakMK committed Jul 2, 2024
1 parent b49bccc commit 82c4cec
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion riegeli/base/intrusive_shared_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class

// Support `ExternalRef`.
friend ExternalStorage RiegeliToExternalStorage(IntrusiveSharedPtr* self) {
return ExternalStorage(self->Release(),
return ExternalStorage(const_cast<std::remove_cv_t<T>*>(self->Release()),
[](void* ptr) { Unref(static_cast<T*>(ptr)); });
}

Expand Down
6 changes: 3 additions & 3 deletions riegeli/base/shared_ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ class

// Support `ExternalRef`.
friend ExternalStorage RiegeliToExternalStorage(SharedPtr* self) {
return ExternalStorage(self->Release(), [](void* ptr) {
SharedPtr::DeleteReleased(static_cast<T*>(ptr));
});
return ExternalStorage(
const_cast<std::remove_cv_t<T>*>(self->Release()),
[](void* ptr) { SharedPtr::DeleteReleased(static_cast<T*>(ptr)); });
}

// Support `MemoryEstimator`.
Expand Down

0 comments on commit 82c4cec

Please sign in to comment.