[Webkit-unassigned] [Bug 205617] Add makeRefCounted<>

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri Jan 3 09:00:49 PST 2020


--- Comment #10 from Alex Christensen <achristensen at apple.com> ---
(In reply to Antti Koivisto from comment #9)
> (In reply to Alex Christensen from comment #7)
> > Another approach is something like what we've done in classes like
> > CustomHeaderFields.  We templatize the create function to just call whatever
> > constructor it can.  This templatized create can be moved to RefCounted and
> > ThreadSafeRefCounted, but then we would need to befriend that class (like we
> > do in many places with our "friend class NeverDestroyed" instances) or have
> > a public constructor.
> What would this achieve?

This would make it so we get a static create function that takes whatever the parameters of the constructor are without having to write one each time.

I think the intent of having private constructors and static create functions was to prevent accidentally making RefCounted types on the stack.  If we had public constructors then we could have something like this:

RefCountedType a { 1, 2 };

Whether we go with makeRefCounted or stick with create, I think we should keep private constructors and befriend something if necessary.

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/20200103/f0ee8652/attachment.htm>

More information about the webkit-unassigned mailing list