polymorphic_value icon indicating copy to clipboard operation
polymorphic_value copied to clipboard

Make null-state non-observable

Open jbcoe opened this issue 2 years ago • 3 comments

Make default constructor private. Make null-state only accessible via a move. Replace operator bool with valueless_by_move.

jbcoe avatar Jul 23 '22 13:07 jbcoe

Docs need updating to merge this but I want to see what the API and coverage stats look like.

jbcoe avatar Jul 23 '22 13:07 jbcoe

Codecov Report

Merging #120 (edf3ea7) into main (8f42b54) will decrease coverage by 1.26%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #120      +/-   ##
==========================================
- Coverage   96.63%   95.36%   -1.27%     
==========================================
  Files           2        2              
  Lines         505      410      -95     
==========================================
- Hits          488      391      -97     
- Misses         17       19       +2     
Impacted Files Coverage Δ
polymorphic_value.h 87.69% <100.00%> (-2.09%) :arrow_down:
polymorphic_value_test.cpp 98.92% <100.00%> (-0.26%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 8f42b54...edf3ea7. Read the comment docs.

codecov[bot] avatar Jul 23 '22 13:07 codecov[bot]

There is also valueless_by_exception as in variant. I didn't think about the moved from state. This even more suggests that disallowing empty state is futile. With SBO the moved from object is still available and can be returned unless the object is larger than the SBO buffer.

BengtGustafsson avatar Aug 04 '22 11:08 BengtGustafsson

We are abandoning this approach due to undesirable semantics of optional types with pointer-like interfaces.

jbcoe avatar Oct 14 '22 12:10 jbcoe