3 ms·
In theory, C++ programs use std::optional, just as Rust programs use std::option. In practice, such C++ programs are extremely rare, whereas such Rust programs
by sanxiyn 5y ago
In theory, C++ programs use std::optional, just as Rust programs use std::option. In practice, such C++ programs are extremely rare, whereas such Rust programs are majority.
- nicoburns 5y agoThere's an even clearer example here: dereferencing a C++ std::optional is undefined behaviour. Dereferencing a Rust std::Option is a compile time error.
- pjmlp 5y agoIn theory, in practice when using debug libraries, undefined becomes defined as a runtime check that will lead to an assertion error, or a static analyser failure. https://godbolt.org/z/re51ensMe https://godbolt.org/z/re51ensMe terminate called after throwing an instance of 'std::bad_optional_access' what(): bad optional access Naturally not everyone goes by adopting best practices, so there is that.