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

void -> tl::expected<void, error_type_enum> is not possible when void is return of a function, not {} #152

Open
Arniiiii opened this issue Aug 8, 2023 · 0 comments

Comments

@Arniiiii
Copy link

Arniiiii commented Aug 8, 2023

enum class unexpected_error_find_in_map {
 NotFound,
 ShitHappened
};
void a_foo(...) { ... }

tl::expected<return_type_of_a_foo, unexpected_error_find_in_map> function(...) {
...
return a_foo(...);
}

error: could not convert ...(function place and name )
from ‘void’ to ‘tl::expected<void, unexpected_error_find_in_map>’

the problem appears when

return a_function_which_returns_void(...);

but not when

return {}

Current solution:

if constexpr( return_type_is_void ) {
the_function(...);
return {};
} else {
return the_function(...);
}

I don't know at which side the problem.

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

No branches or pull requests

1 participant