chromium / subspace

A concept-centered standard library for C++20, enabling safer and more reliable products and a more modern feel for C++ code.; Also home of Subdoc the code-documentation generator.
https://suslib.cc
Apache License 2.0
89 stars 15 forks source link

Option<T> converts to Option<U> if T converts to U #388

Closed danakj closed 1 year ago

danakj commented 1 year ago

This also implies From<Option, Option>.

This is important for inheritance/subtyping, to be able to up-cast. Once downcast exists, we could consider a downcast method on option, though Rust gets away without that (but also has no inheritance).

It also allows you to return Option(3) when the return type is Option, though some(3) will do a better job.

Closes #384