Skip to content

Commit

Permalink
Fix building under MSVC: move the body of
Browse files Browse the repository at this point in the history
`friend void RiegeliReset(absl::Cord*, ExternalRef)` to a private function.

It accesses a private member of `StorageBase` which grants friendship to
`class ExternalRef`, but this does not necessarily reach friend functions
defined in `ExternalRef`.

PiperOrigin-RevId: 660801552
  • Loading branch information
QrczakMK committed Aug 8, 2024
1 parent 47a520b commit b975369
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions riegeli/base/external_ref_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -1932,16 +1932,7 @@ class ExternalRef {

// Support `riegeli::Reset(absl::Cord&, ExternalRef)`.
friend void RiegeliReset(absl::Cord& dest, ExternalRef src) {
std::move(*src.storage_)
.ToCord(
cord_internal::kMaxBytesToCopyToEmptyCord, &dest,
[](void* context, absl::string_view data) {
cord_internal::AssignToBlockyCord(
data, *static_cast<absl::Cord*>(context));
},
[](void* context, absl::Cord data) {
*static_cast<absl::Cord*>(context) = std::move(data);
});
std::move(src).AssignTo(dest);
}

// Appends the data to `dest`.
Expand Down Expand Up @@ -2017,6 +2008,19 @@ class ExternalRef {
});
}

// Assigns the data to `dest`.
void AssignTo(absl::Cord& dest) && {
std::move(*storage_).ToCord(
cord_internal::kMaxBytesToCopyToEmptyCord, &dest,
[](void* context, absl::string_view data) {
cord_internal::AssignToBlockyCord(data,
*static_cast<absl::Cord*>(context));
},
[](void* context, absl::Cord data) {
*static_cast<absl::Cord*>(context) = std::move(data);
});
}

// Appends the data to `dest`.
void AppendTo(Chain& dest) && {
std::move(*storage_).ToChainBlock(
Expand Down

0 comments on commit b975369

Please sign in to comment.