Prevent Result<const V, E> or Result<V, const E> from being instantiated
Categories
(Core :: MFBT, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox82 | --- | fixed |
People
(Reporter: sg, Assigned: sg)
References
Details
Attachments
(1 file)
Result<const V, E>
is not meaningful to express that the success value must not be changed within a Result
, because Result
provides this guarantee anyway. OTOH, when unwrap
ping the value, const
has no effect, it is still possible to unwrap into a non-const V
.
However, Result<const V, E>
has the negative side-effect of preventing moving instances of that type. To prevent this, and to avoid confusion on the effect of const V
, this should be prevented via a static_assert
.
Also, documentation should be extended to make the non-modifiability of the success value clear(er) to developers using and evolving Result
.
Note that Result<const V*, E>
remains possible and useful, just Result<const V* const, E>
will no longer be possible.
Assignee | ||
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
Same goes for const E
.
Assignee | ||
Comment 2•4 years ago
|
||
Also, remove the existing uses of Result<const nsCString, nsresult> in URLPreloader
and Result<CryptoScheme, const nsCString> in SampleIterator.
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/52ef06111f20 Prevent Result<const V, E> or Result<V, const E> from being instantiated. r=froydnj
Comment 4•4 years ago
|
||
bugherder |
Description
•