From 8f10ed18632ebba06983d9950365e459e87ed605 Mon Sep 17 00:00:00 2001 From: Daniel Holbert Date: Wed, 4 Oct 2023 18:49:03 +0000 Subject: [PATCH] Bug 1856746: Extend already_AddRefed documentation to mention a case where it makes sense as a function parameter. r=nika DONTBUILD because comment-only Differential Revision: https://phabricator.services.mozilla.com/D189987 --- mfbt/AlreadyAddRefed.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mfbt/AlreadyAddRefed.h b/mfbt/AlreadyAddRefed.h index 3b4ae8885568..fd2b7f52bd63 100644 --- a/mfbt/AlreadyAddRefed.h +++ b/mfbt/AlreadyAddRefed.h @@ -24,7 +24,10 @@ struct unused_t; * already_AddRefed cooperates with reference counting smart pointers to enable * you to assign in a pointer _without_ |AddRef|ing it. You might want to use * this as a return type from a function that returns an already |AddRef|ed - * pointer. + * pointer. Or, you might want to use this as a parameter type in a function + * that wants to force a transfer-of-ownership from a RefPtr in the caller (for + * example, if the function expects callers to pass in a newly-created object, + * which the function then takes ownership of). * * TODO Move already_AddRefed to namespace mozilla. This has not yet been done * because of the sheer number of usages of already_AddRefed.