Skip to content

Commit

Permalink
refine
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 17, 2024
1 parent 4dcd799 commit 3b642d2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/core/lib/gprpp/ref_counted.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,17 @@ class RefCounted : public Impl {
std::enable_if_t<std::is_base_of<Child, Subclass>::value, bool> = true>
RefCountedPtr<Subclass> RefAsSubclass() {
IncrementRefCount();
return RefCountedPtr<Subclass>(down_cast<Subclass*>(this));
return RefCountedPtr<Subclass>(
down_cast<Subclass*>(static_cast<Child*>(this)));
}
template <
typename Subclass,
std::enable_if_t<std::is_base_of<Child, Subclass>::value, bool> = true>
RefCountedPtr<Subclass> RefAsSubclass(const DebugLocation& location,
const char* reason) {
IncrementRefCount(location, reason);
return RefCountedPtr<Subclass>(down_cast<Subclass*>(this));
return RefCountedPtr<Subclass>(
down_cast<Subclass*>(static_cast<Child*>(this)));
}

// RefIfNonZero() for mutable types.
Expand Down

0 comments on commit 3b642d2

Please sign in to comment.