aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib
diff options
context:
space:
mode:
authorGravatar Mark D. Roth <roth@google.com>2017-11-28 08:31:08 -0800
committerGravatar Mark D. Roth <roth@google.com>2017-11-28 08:31:08 -0800
commit835537fbc78f083e311dfec148d2b25d74af78e8 (patch)
treeb5868992c4dc801116686a3846850be2f4ab7957 /src/core/lib
parentcf9ca843eb3dec132195e8a8b21f33a7525d2197 (diff)
Implement MakeReferenceCounted<> helper.
Diffstat (limited to 'src/core/lib')
-rw-r--r--src/core/lib/support/reference_counted_ptr.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/core/lib/support/reference_counted_ptr.h b/src/core/lib/support/reference_counted_ptr.h
index 48a763ebe0..71d5c36d52 100644
--- a/src/core/lib/support/reference_counted_ptr.h
+++ b/src/core/lib/support/reference_counted_ptr.h
@@ -19,6 +19,10 @@
#ifndef GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_PTR_H
#define GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_PTR_H
+#include <utility>
+
+#include "src/core/lib/support/memory.h"
+
namespace grpc_core {
// A smart pointer class for objects that provide Ref() and Unref() methods,
@@ -76,6 +80,11 @@ class ReferenceCountedPtr {
T* value_ = nullptr;
};
+template<typename T, typename... Args>
+inline ReferenceCountedPtr<T> MakeReferenceCounted(Args&&... args) {
+ return ReferenceCountedPtr<T>(New<T>(std::forward<Args>(args)...));
+}
+
} // namespace grpc_core
#endif // GRPC_CORE_LIB_SUPPORT_REFERENCE_COUNTED_PTR_H