Bug 176228 - std::optional<Ref> should be as compact as RefPtr
Summary: std::optional<Ref> should be as compact as RefPtr
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Web Template Framework (show other bugs)
Version: WebKit Nightly Build
Hardware: All All
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-09-01 10:14 PDT by Filip Pizlo
Modified: 2017-09-01 21:27 PDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Filip Pizlo 2017-09-01 10:14:10 PDT
This seems like something we could specialize.
Comment 1 Alex Christensen 2017-09-01 11:02:46 PDT
Can we make the specialization copyable like RefPtr is?
If we make a specialization of std::optional<Ref<T>> with the intent of saving memory, should we make similar specializations of std::optional<T&> and std::optional<bool>?
Comment 2 Filip Pizlo 2017-09-01 11:03:48 PDT
(In reply to Alex Christensen from comment #1)
> Can we make the specialization copyable like RefPtr is?
> If we make a specialization of std::optional<Ref<T>> with the intent of
> saving memory, should we make similar specializations of std::optional<T&>
> and std::optional<bool>?

I would use std::optional more if I had such specializations.
Comment 3 Yusuke Suzuki 2017-09-01 21:27:05 PDT
(In reply to Alex Christensen from comment #1)
> Can we make the specialization copyable like RefPtr is?
> If we make a specialization of std::optional<Ref<T>> with the intent of
> saving memory, should we make similar specializations of std::optional<T&>
> and std::optional<bool>?

We already have std::optional<T&> specialization in Optional.h.
I would like to strongly support adding std::optional<bool>, which is super commonly shown pattern (tristate).