|
|
|
|
|
by sapiogram
691 days ago
|
|
> Well, clearly there is a need for a special value that is not part of the set of legal values. There's a neat trick available here: If you make zero an illegal value for the pointer itself, you can use zero as your "special value" for the std::optional wrapper, and the performance overhead goes away. This is exactly what Rust does, and as a result, Option<&T>, Option<Box<T>>, etc are guaranteed to have zero overhead: https://doc.rust-lang.org/std/option/index.html#representati... |
|