Allow implicit conversion from result<T, E>
to result<void, E>
#13
an-inconspicuous-semicolon
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
Implicit discarding seems a bit odd in my opinion, is there a reason you aren't I've also found a section in the tutorial: https://github.com/bitwizeshift/result/blob/master/doc/tutorial.md#type-erasure-with-resultvoide
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was making a project using the results, and its working fantastic so far. However, since my project is a library and I don't want to "expose" third party code to the client, so I use macros for certain types.
result
happens to be one of these types, and because it is a template that requires a generic case, I have a macro calledVEN_RESULT
which looks like thisbut since I don't want the client (or me), to use the
VEN_RESULT_TYPED
if they only care if a function succeeds or not. so they can useVEN_RESULT
instead.Now the problem. There is no implicit conversion from
result<T, E>
toresult<void, E>
which means that I have to write calls to the function as follows:The solution for this would be to allow implicit conversion in the
result
class toresult<void, E>
doing this is simple, its just changing a couple of definitions to remove
explicit
If this is done, the code above could be written as:
which I think is cleaner and easier to read.
Beta Was this translation helpful? Give feedback.
All reactions