[Webkit-unassigned] [Bug 233384] Ref<T> should support indirection operator *

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Nov 19 15:36:58 PST 2021


Alex Christensen <achristensen at apple.com> changed:

           What    |Removed                     |Added
                 CC|                            |achristensen at apple.com

--- Comment #1 from Alex Christensen <achristensen at apple.com> ---
To me, the indirection operator is used when you have something that might be null/nullopt/error, so you check if (thing) { useThing(*thing); } but that isn't the case with Ref.  It never needs checking whether it's null because if you haven't used it after you moved from it, it's never null.  Adding the indirection operator would make it so when we write code that just calls useThing(*thing), we now have to think about whether it is a Ref or not.  Also, when someone down the line changes thing from a Ref to a RefPtr, we would then have code that may not be nearby that needs a null check, but you didn't notice it because it compiled fine.  This really needs operator dot, but C++ doesn't allow that.  It currently follows the convention of unique_ptr<T>::get which returns a T*, but it returns a T&.

Maybe we could implement Ref<T>::operator& instead of Ref<T>::ptr to get a T*, though.  That would be nicer syntactically.

You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-unassigned/attachments/20211119/1144247c/attachment.htm>

More information about the webkit-unassigned mailing list