4 ms·
Your example doesn't tell me which I have. It's assuming that err = 0 means success, but that's an assumption not a contract of the type. By comparison some so
by kllrnohj 8y ago
Your example doesn't tell me which I have. It's assuming that err = 0 means success, but that's an assumption not a contract of the type.
By comparison some something like https://github.com/oktal/result https://github.com/oktal/result will tell you if it's a success or error without any magic error codes that actually mean success.
You could do this with a type bit + union in C, it's just more painful without templates