RefCountedPtr: Explicit constructor (#28157)

* RefCountedPtr: Explicit constructor

* Explicit constructor for WeakRefCountedPtr
pull/28234/head
Yash Tibrewal 3 years ago committed by GitHub
parent 396fdf2991
commit 789e8b33c8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/core/ext/filters/client_channel/dynamic_filters.cc
  2. 9
      src/core/ext/xds/xds_bootstrap.cc
  3. 6
      src/core/lib/gprpp/ref_counted_ptr.h

@ -184,7 +184,7 @@ RefCountedPtr<DynamicFilters::Call> DynamicFilters::CreateCall(
channel_stack_->call_stack_size;
Call* call = static_cast<Call*>(args.arena->Alloc(allocation_size));
new (call) Call(std::move(args), error);
return call;
return RefCountedPtr<DynamicFilters::Call>(call);
}
} // namespace grpc_core

@ -59,11 +59,14 @@ RefCountedPtr<grpc_channel_credentials>
XdsChannelCredsRegistry::MakeChannelCreds(const std::string& creds_type,
const Json& /*config*/) {
if (creds_type == "google_default") {
return grpc_google_default_credentials_create(nullptr);
return RefCountedPtr<grpc_channel_credentials>(
grpc_google_default_credentials_create(nullptr));
} else if (creds_type == "insecure") {
return grpc_insecure_credentials_create();
return RefCountedPtr<grpc_channel_credentials>(
grpc_insecure_credentials_create());
} else if (creds_type == "fake") {
return grpc_fake_transport_security_credentials_create();
return RefCountedPtr<grpc_channel_credentials>(
grpc_fake_transport_security_credentials_create());
}
return nullptr;
}

@ -40,8 +40,7 @@ class RefCountedPtr {
// If value is non-null, we take ownership of a ref to it.
template <typename Y>
// NOLINTNEXTLINE(google-explicit-constructor)
RefCountedPtr(Y* value) : value_(value) {}
explicit RefCountedPtr(Y* value) : value_(value) {}
// Move ctors.
RefCountedPtr(RefCountedPtr&& other) noexcept {
@ -191,8 +190,7 @@ class WeakRefCountedPtr {
// If value is non-null, we take ownership of a ref to it.
template <typename Y>
// NOLINTNEXTLINE(google-explicit-constructor)
WeakRefCountedPtr(Y* value) {
explicit WeakRefCountedPtr(Y* value) {
value_ = value;
}

Loading…
Cancel
Save