-
Notifications
You must be signed in to change notification settings - Fork 135
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Is expected::error() ment to throw if it contains a value. #113
Comments
As a follow up, I found the original author implementation and there solution is to use assert's to safe guard this. |
According to the documentation, it is undefined behaviour. Other instances of undefined behaviour are to use I agree with you; the behaviour should retain memory safety. There is no performance benefit to leaving this as undefined behaviour, because in practice correct code will look something like this:
Suppose that For our use of Note that this change does not introduce an incompatibility with any version of the |
This affects operator->, operator*, and error() on a tl::expected instance. The performance impact is likely negligible for typical uses. refs TartanLlama#113 Signed-off-by: Daira Hopwood <[email protected]>
This affects operator->, operator*, and error() on a tl::expected instance. The performance impact is likely negligible for typical uses. refs TartanLlama#113 Signed-off-by: Daira Hopwood <[email protected]>
This affects operator->, operator*, and error() on a tl::expected instance. The performance impact is likely negligible for typical uses. refs TartanLlama#113 Signed-off-by: Daira Hopwood <[email protected]>
* Add assertions for cases where the API documents undefined behaviour. This affects operator->, operator*, and error() on a tl::expected instance. The performance impact is likely negligible for typical uses. refs #113 Signed-off-by: Daira Hopwood <[email protected]> * Add tests for assertions. Signed-off-by: Daira Hopwood <[email protected]> * Add documentation for assertion behaviour. Signed-off-by: Daira Hopwood <[email protected]> --------- Signed-off-by: Daira Hopwood <[email protected]>
Sorry if this has already been answered, but I found this odd behaviour.
When I do the following test
I get
I would have expected it to throw a bad_expected_access equivalent, like accessing value() when is set to unexpected.
The text was updated successfully, but these errors were encountered: