mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1665026 - Prevent ToResultInvoke from being instantiated with a raw pointer result type. r=janv
Differential Revision: https://phabricator.services.mozilla.com/D90264
This commit is contained in:
parent
084f4ffe27
commit
ab0b7510ad
@ -66,6 +66,14 @@ template <typename R, typename RArgMapper, typename Func, typename... Args>
|
||||
Result<R, nsresult> ToResultInvokeInternal(const Func& aFunc,
|
||||
const RArgMapper& aRArgMapper,
|
||||
Args&&... aArgs) {
|
||||
// XXX Thereotically, if R is a pointer to a non-refcounted type, this might
|
||||
// be a non-owning pointer, but unless we find a case where this actually is
|
||||
// relevant, it's safe to forbid any raw pointer result.
|
||||
static_assert(
|
||||
!std::is_pointer_v<R>,
|
||||
"Raw pointer results are not supported, please specify a smart pointer "
|
||||
"result type explicitly, so that getter_AddRefs is used");
|
||||
|
||||
R res;
|
||||
nsresult rv = aFunc(std::forward<Args>(aArgs)..., aRArgMapper(res));
|
||||
if (NS_FAILED(rv)) {
|
||||
|
Loading…
Reference in New Issue
Block a user