Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 17, 2024
1 parent 43d2b28 commit 4dcd799
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/core/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,7 @@ grpc_cc_library(
public_hdrs = ["lib/gprpp/ref_counted.h"],
deps = [
"atomic_utils",
"down_cast",
"//:debug_location",
"//:gpr",
"//:ref_counted_ptr",
Expand Down
5 changes: 3 additions & 2 deletions src/core/lib/gprpp/ref_counted.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "src/core/lib/gprpp/atomic_utils.h"
#include "src/core/lib/gprpp/debug_location.h"
#include "src/core/lib/gprpp/down_cast.h"
#include "src/core/lib/gprpp/ref_counted_ptr.h"

namespace grpc_core {
Expand Down Expand Up @@ -310,15 +311,15 @@ class RefCounted : public Impl {
std::enable_if_t<std::is_base_of<Child, Subclass>::value, bool> = true>
RefCountedPtr<Subclass> RefAsSubclass() {
IncrementRefCount();
return RefCountedPtr<Subclass>(static_cast<Subclass*>(this));
return RefCountedPtr<Subclass>(down_cast<Subclass*>(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>(static_cast<Subclass*>(this));
return RefCountedPtr<Subclass>(down_cast<Subclass*>(this));
}

// RefIfNonZero() for mutable types.
Expand Down

0 comments on commit 4dcd799

Please sign in to comment.