Closed Bug 1680724 Opened 5 years ago Closed 5 years ago

Add a utility function that converts a T* to a Maybe<T&>

Categories

(Core :: MFBT, task)

task

Tracking

()

RESOLVED FIXED
85 Branch
Tracking Status
firefox85 --- fixed

People

(Reporter: sg, Assigned: sg)

Details

Attachments

(2 files)

It would be convenient to have a utility function that converts a potentially nullptr T* to a Maybe<T&> like:

template<typename T>
Maybe<T&> ToMaybeRef(T* const aPtr) {
  return aPtr ? SomeRef(*aPtr) : Nothing{};
}
Assignee: nobody → sgiesecke
Status: NEW → ASSIGNED
Attachment #9191328 - Attachment description: Bug 1680724 - Use ToMaybeRef where possible. r=#dom-workers-and-storage → Bug 1680724 - Use ToMaybeRef or SafeRefPtr::maybeDeref where possible. r=#dom-workers-and-storage
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/7264e6cb9041 Add a utility function that converts a T* to a Maybe<T&>. r=jwalden https://hg.mozilla.org/integration/autoland/rev/79190513b660 Use ToMaybeRef or SafeRefPtr::maybeDeref where possible. r=dom-workers-and-storage-reviewers,janv
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 85 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: