Skip to content
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

Compile error with move-only custom payload and void value type #291

Closed
gix opened this issue Nov 13, 2023 · 2 comments
Closed

Compile error with move-only custom payload and void value type #291

gix opened this issue Nov 13, 2023 · 2 comments
Labels

Comments

@gix
Copy link
Contributor

gix commented Nov 13, 2023

Given the following custom error code:

struct MovableError
{
    MovableError() = default;
    MovableError(MovableError&&) = default;
    MovableError& operator=(MovableError&&) = default;
};

std::error_code make_error_code(MovableError const& error);
void outcome_throw_as_system_error_with_payload(MovableError error);

template<typename T>
using MyResult = result<T, MovableError>;

MyResult<int> f();
MyResult<void> g();

f().value() compiles, but g().value() does not. It wants to copy MovableError when calling outcome_throw_as_system_error_with_payload since the Impl passed to wide_value_check is const.

Looks like the void-specialization of basic_result_value_observers is missing a non-const value() overload.

@ned14 ned14 added the bug label Nov 14, 2023
@ned14
Copy link
Owner

ned14 commented Nov 14, 2023

Verified: https://godbolt.org/z/Y85hYz71b

Thanks for the BR!

@ned14 ned14 closed this as completed in f7892ac Nov 17, 2023
@ned14
Copy link
Owner

ned14 commented Nov 17, 2023

This is fixed in develop branch, I'll seek permission to get it into the Boost 1.84 release which is currently within release cycle.

Thanks for the BR, it's interesting four years passed before anybody noticed this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants