Skip to content

p0323r7 avoid explicit throw an exception, including bad_access_expected #1493

@raidenluikang

Description

@raidenluikang

Is p0323r7 adopted by c++23 ?

std::expected very good candidate for alternative exceptions error-code principle. But there access value methods throw the exception bad_access_expected: again the exception! std::expected already have has_value method to check this situation.

Yes, std::optional::value() also throws exception, but std::expected specially class for exception-free code, in my opinion.

I personally thought about, why can't to remove explicit throwing any exception ?

For example, std::move_only_function's call "empty" state no more throws bad_functional_call exception, it simply cause an UB.

Pls, remove bad_access_expected class, and do not throw an any exception, explicitly! Let value() cause an UB, if there error state.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions